Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Instructions Perform the tasks and answer the questions using Python code ( Jupyter notebook ) . Take screenshots of your work and paste them. To
Instructions
Perform the tasks and answer the questions using Python code Jupyter notebook Take screenshots of your work and paste them.
To start performing each task, import the Numpy and pandas library and give it an appropriate alias name. Find the version of the pandas package on your system.
In performing the tasks in this assignment, consider the sales data and advertising expenses from January to December:
Month AdExp Sales
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
Task
Create a dictionary of the sales data using Month as index.
Task
Create a pandas series using the sales dictionary created above.
i Print all the months from the series.
ii Print all the sales value from the series.
iii Print the sales for the last months JulDec
iv Change the sales for Jun to in the series object.
v Display all months when sales was above
vi Find the average sales for the months.
vii There has been additional sale of and in the month of Aug, Sep and Oct respectively. Create a series of this additional sales for the mentioned months. Find the total sales across the months considering the additional sales.
viii Display the months with minimum and maximum sales consider the additional sales given in vii
Task
Create a numpy array using the original data given above for AdExp and Sales.
Task
Using the numpy array in Task create a dataframe with months as index and the given column names above.
i Select and display the AdExp and Sales values for Mar, Apr and May.
ii Select and display AdExp for Nov.
iii Select and display Sales for Feb.
iv Create a new column "NetSales" which is the difference of Sales and AdExp Sales AdExp
v Find the average value of "AdExp", "Sales" and "NetSales".
vi Find the sum of Sales for the months.
vii Get the min, max, median, standard deviation, percentile value, percentile value and the average of "AdExp", "Sales" and "NetSales" using a single function.
viii Sort the data by Sales in descending order and display.
ix Include the index as a column in the dataframe. Change the column name to "Month". Hint: Use the resetindex and rename function.
x Write the data into a csv file "Sale.csv Exclude the index while writing into the file.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started