-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTotal_sales.py
More file actions
28 lines (20 loc) · 862 Bytes
/
Total_sales.py
File metadata and controls
28 lines (20 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# Read and store the csv
data_frame = pd.read_csv("./Pandas Hackathon Files/HackathonDataset.csv")
#
data_frame = data_frame.sort_values('transaction_date')
# Convert each entry into a float without "$"
order_amount_frame = (data_frame['order_amt'].str[1:]).astype(float)
# Sum the values
total_sales = order_amount_frame.sum()
# Find average revenue per transaction
average_transaction = order_amount_frame.mean()
#Graphing the consecutive revenue
consecutive_revinue = order_amount_frame.cumsum()
data_frame = pd.concat([pd.to_datetime(data_frame['transaction_date']),consecutive_revinue/1000000], axis=1)
data_frame.plot(title='Revenue over Time', x='transaction_date', y='order_amt', legend=False)
plt.ylabel('Total Revenue(in millions of dollars)')
plt.xlabel('Date')
plt.show()