codecademy-examples/aggregates/python-aggregatesV.py
Jonathan Ervine 2ba94913fb new file: aggregates/a-b project/ad_click.csv
new file:   aggregates/a-b project/code.py
	new file:   aggregates/codecademy_code/script.py
	new file:   aggregates/codecademy_code/test1.py
	modified:   aggregates/orders.csv
	new file:   aggregates/python-aggregatesI.py
	new file:   aggregates/python-aggregatesII.py
	new file:   aggregates/python-aggregatesIII.py
	new file:   aggregates/python-aggregatesIV.py
	new file:   aggregates/python-aggregatesV.py
Added aggregate files
2020-03-17 17:02:38 +08:00

18 lines
487 B
Python

import pandas as pd
orders = pd.read_csv('orders.csv')
print(orders.head(10))
print(user_visits.head(10))
click_source = user_visits.groupby('utm_source').id.count().reset_index()
print(click_source)
click_source_by_month = user_visits.groupby(['utm_source', 'month']).id.count().reset_index()
print(click_source_by_month)
click_source_by_month_pivot = click_source_by_month.pivot(columns='month', index='utm_source', values='id').reset_index()
print(click_source_by_month_pivot)