Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create analyze.py #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions data/analyze.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import pandas as pd

# Load the three CSV files
sales_data_0 = pd.read_csv('data/daily_sales_data_0.csv')
sales_data_1 = pd.read_csv('data/daily_sales_data_1.csv')
sales_data_2 = pd.read_csv('data/daily_sales_data_2.csv')

# Combine the data from the three files
combined_sales_data = pd.concat([sales_data_0, sales_data_1, sales_data_2])

# Filter rows where the product is Pink Morsels
pink_morsels_data = combined_sales_data[combined_sales_data['product'] == 'Pink Morsels']

# Calculate total sales by multiplying quantity and price
pink_morsels_data['sales'] = pink_morsels_data['quantity'] * pink_morsels_data['price']

# Select and rearrange
formatted_data = pink_morsels_data[['sales', 'date', 'region']]

# Save the formatted data into a single output file
formatted_data.to_csv('formatted_sales_data.csv', index=False)