text_plain_output_1.png
import matplotlib.pyplot as plt

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

type(avo['Date'].iloc[0])
avo['Date'] = pd.to_datetime(avo['Date'])
type(avo['Date'].iloc[0])

avo['Month'] = avo['Date'].apply(lambda x: x.month)
avo.groupby('Month').mean()['AveragePrice'].sort_values(ascending=False).index[0]

avo.drop(avo.loc[avo['region'] == 'TotalUS'].index, inplace=True)
avo.groupby('region').sum()['Total Volume']

avo.groupby('region').sum()['Total Volume'].idxmax()

avo.drop(avo.loc[avo['region'] == 'TotalUS'].index, inplace=True)

avo['Revenue'] = avo['AveragePrice'] * avo['Total Volume']
c = avo.groupby('type').sum()['Revenue']['conventional']
o = avo.groupby('type').sum()['Revenue']['organic']
o - c

a = pd.DataFrame(avo.groupby(['region', 'type']).sum()['Total Volume'].values.reshape((-1, 2)))
a['ratio'] = a[1] / a[0]
a['region'] = avo['region'].unique()
a.set_index('region', inplace=True)
a