Answered step by step
Verified Expert Solution
Link Copied!

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 165000
Feb 20.714000
Mar 26.536000
Apr 30.640000
May 32.349000
Jun 29.57000
Jul 28.352000
Aug 31.365000
Sep 32.217000
Oct 26.45000
Nov 23.417000
Dec 16.41000
Task 1
Create a dictionary of the sales data using Month as index.
Task 2
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 6 months (Jul-Dec).
iv) Change the sales for Jun to 11000 in the series object.
v) Display all months when sales was above 30000.
vi) Find the average sales for the 12 months.
vii) There has been additional sale of 2500,4800 and 3900 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 3
Create a numpy array using the original data given above for AdExp and Sales.
Task 4
Using the numpy array in Task 3, 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 "Net_Sales" which is the difference of Sales and AdExp (Sales -AdExp).
v) Find the average value of "AdExp", "Sales" and "Net_Sales".
vi) Find the sum of Sales for the 12 months.
vii) Get the min, max, median, standard deviation, 25 percentile value, 75 percentile value and the average of "AdExp", "Sales" and "Net_Sales" 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 reset_index() 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

What is measurement?

Answered: 1 week ago