M3 Gathering Information for Better Data Understanding

.docx

School

Houston Community College *

*We aren’t endorsed by this school

Course

101

Subject

Industrial Engineering

Date

Feb 20, 2024

Type

docx

Pages

3

Uploaded by mmike786

Report
Write a python script that uses pandas dataframes to find the following: 1. The total number of purchases per product type. o There are three product types sold by this etsy store: Framed Posters, Canvas Paintings & Poster Prints. o Find the total number of purchases for each product type. o Which product has the highest purchase count? o To solve this part, you can load the csv file into a dataframe, extract the product_type column and apply the value_counts() function to it. Code: import pandas as pd import numpy as np df=pd.read_csv("C:/Users/maira/OneDrive/Desktop/IFT 511 Big Data/M3/sales.csv") print(df['product_type'].value_counts()) ScreenShot:
2. The total number of purchases per month. o First, extract the purchase_date column from the dataframe. o Next, use the pandas DatetimeIndex class to extract the month from the purchase_date attribute. Use this page as a reference: https://www.interviewqs.com/ddi-code- snippets/extract-month-year-pandas (Links to an external site.) o Finally, apply the value_counts() function to the extracted months to get the total number of purchases per month. o Can you use the month_name() function instead of month to show the month names instead of the month numbers? Check this page for reference: https://pandas.pydata.org/pandas-docs/stable/reference/api/pan das.DatetimeIndex.month_name.html (Links to an external site.) Code: import pandas as pd df=pd.read_csv("C:/Users/maira/OneDrive/Desktop/IFT 511 Big Data/M3/sales.csv") df['month_name']=pd.DatetimeIndex(df['purchase_date']).month_name() df=df.value_counts() print(df)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help