In [ ]: In [ ]: In [ ]: In [ ]: ord_no purch_amt ord_date customer_id...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
In [ ]: In [ ]: In [ ]: In [ ]: ord_no purch_amt ord_date customer_id salesman_id 0 70001 150.50 2012-10-05 3005 5002 1 70009 270.65 2012-09-10 3001 5005 2 70002 65.26 2012-10-05 3002 5001 3 70004 110.50 2012-08-17 3009 5003 4 70007 948.50 2012-09-10 3005 5002 5 70005 2400.60 2012-07-27 3007 5001 6 70008 5760.00 2012-09-10 3002 5001 7 70010 1983.43 2012-10-10 3004 5006 8 70003 2480.40 2012-10-10 3009 5003 9 70012 250.45 2012-06-27 3008 5002 10 70011 75.29 2012-08-17 3003 5007 11 70013 3045.60 2012-04-25 3002 5001 Q6. Create a Pandas dataframe to store above dataset. The ord_date should be used as row index and stored as timeseries (not stored as character string!) Q7. Write a Pandas program to calculate the monthly total purchase amount (purch_amt). You only need to consider the months that exist in above dataset. Q8. Use pivot function the re-organize the dataset such that each row represent a salesman, each column represent a customer, and each element in the table represents the purchase amount. Q9. For each row, let variable "previous_month_sales" be the total purch_amt of the corresponding salesman in previous month. For example, for the first row, salesman_id=5002 and order date is in Oct. Then you need to find the total sales of salesman_id=5002 in Sep. If there is no data, set previous_month_sales as 0. Write a Pandas program to calculate the value of variable previous_month_sales for each row. In [ ]: In [ ]: In [ ]: In [ ]: ord_no purch_amt ord_date customer_id salesman_id 0 70001 150.50 2012-10-05 3005 5002 1 70009 270.65 2012-09-10 3001 5005 2 70002 65.26 2012-10-05 3002 5001 3 70004 110.50 2012-08-17 3009 5003 4 70007 948.50 2012-09-10 3005 5002 5 70005 2400.60 2012-07-27 3007 5001 6 70008 5760.00 2012-09-10 3002 5001 7 70010 1983.43 2012-10-10 3004 5006 8 70003 2480.40 2012-10-10 3009 5003 9 70012 250.45 2012-06-27 3008 5002 10 70011 75.29 2012-08-17 3003 5007 11 70013 3045.60 2012-04-25 3002 5001 Q6. Create a Pandas dataframe to store above dataset. The ord_date should be used as row index and stored as timeseries (not stored as character string!) Q7. Write a Pandas program to calculate the monthly total purchase amount (purch_amt). You only need to consider the months that exist in above dataset. Q8. Use pivot function the re-organize the dataset such that each row represent a salesman, each column represent a customer, and each element in the table represents the purchase amount. Q9. For each row, let variable "previous_month_sales" be the total purch_amt of the corresponding salesman in previous month. For example, for the first row, salesman_id=5002 and order date is in Oct. Then you need to find the total sales of salesman_id=5002 in Sep. If there is no data, set previous_month_sales as 0. Write a Pandas program to calculate the value of variable previous_month_sales for each row.
Expert Answer:
Answer rating: 100% (QA)
To achieve the tasks described in Q6Q9 you can use the following Python code with Pandas import pand... View the full answer
Related Book For
Essentials of Database Management
ISBN: 978-0133405682
1st edition
Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman
Posted Date:
Students also viewed these programming questions
-
Pitt Company produces oak lumber that the company sells to furniture produces. A new customer has approached Pitt Company looking to purchase a special load of lumber. The customer has requested...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
List three specific parts of the Case Guide, Objectives and Strategy Section (See below) that you had the most difficulty understanding. Describe your current understanding of these parts. Provide...
-
Samson Company manufactures embroidered jackets. The company uses a standard cost system to control manufacturing costs. The following data represent the standard unit cost of a jacket: Fixed...
-
Divine Apparel has 3,000 shares of common stock outstanding. On October 1, the company declares a $0.50 per share dividend to stockholders of record on October 15. The dividend is paid on October 31....
-
Write a program that prompts the user to enter a letter grade A, B, C, D, or F and displays its corresponding numeric value 4, 3, 2, 1, or 0. For other input, display invalid grade. Here is a sample...
-
Explain the nature and roles of accounting and finance.
-
A U.S. company purchases inventory from a foreign vendor and purchases are denominated in the foreign currency (FC). The U.S. dollar is expected to weaken against the FC. Explain how a forward...
-
An analyst studying Albion Industries determines that the average EV/EBITDA ratio for Albion's industry is 10. The analyst obtains the following information from Albion's financial statements: EBITDA...
-
Perform the vertical and horizontal analysis and calculate the ratios as instructed (40 points) Fill the grey cells by using Excel formulas or cells referencing NOT hardcoding. You will not earn...
-
Sue inherited 50 shs of Zoll Industry stock from her Uncle Dave. Dave purchased the stock in 1986 at $20/sh. The stock was worth $50/sh when Dave passed away. What is Sues basis in the stock? $1,000...
-
Your local bank is offering 6% APR on new savings account and you have calculated the EAR to be 6.18%. What is the periodic rate expressed as a decimal? You are hoping to have $10,000 in your account...
-
Using the substitution u = 111, write the integral 1/22 (110) dt, as an integral in the variable u.
-
Play the game Investment (All or Nothing) on Moblab. Once you have played the game, address the following questions: 1) How did you do in the game? 2) Did you use a different strategy the second time...
-
Discuss the major differences between adult and juvenile parole. Do you believe the parole system is a critical part of the corrections process? Explain your position and provide at least two support...
-
1. Explain why an individual investor might want to invest in an international growth fund. 2. Describe the risks associated with making an investment in an internationalgrowth fund. Identify the...
-
What Are Examples of Everyday Science?
-
Three forces with magnitudes of 70pounds, 40 pounds, and 60 pounds act on an object at angles of 30, 45, and 135, respectively, with the positive x-axis. Find the direction and magnitude of the...
-
Great Lakes Insurance would like to implement a relational database for both its in-house and outside agents. The outside agents will use notebook computers to keep track of customers and policy...
-
What is the relationship between the primary key of a relation and the functional dependencies among all attributes within that relation?
-
Consider the following normalized relations for a sports league: TEAM(TeamID, TeamName, TeamLocation) PLAYER(PlayerID, PlayerFirstName, PlayerLastName, PlayerDateOfBirth, PlayerSpecialtyCode)...
-
What other services do accountants provide in addition to auditing?
-
What are the time limits for laying and delivery of accounts?
-
Define an audit.
Study smarter with the SolutionInn App