import numpy as np
import pandas as pd
import locale
from locale import atof
rng = pd.date_range('2017-11-01', '2017-11-30', freq='D')
locale.setlocale(locale.LC_NUMERIC, '')
df = pd.DataFrame({'AHT': pd.to_numeric(aht.split('\n')), 'ATT': pd.to_numeric(att.split('\n')),
'HT': pd.to_numeric(ht.split('\n')), 'ACW': pd.to_numeric(acw.split('\n')),
'Calls': pd.to_numeric([atof(val) for val in calls.split('\n')], downcast='integer') }, index=rng)
df.index.name = 'Date'
df.Calls = df.Calls.astype(int)
grouped = df.groupby(lambda x: True)
get_wavg_aht = lambda g: np.average(g['AHT'], weights=g['Calls'])
grouped.apply(get_wavg_aht)
get_wavg_att = lambda g: np.average(g['ATT'], weights=g['Calls'])
grouped.apply(get_wavg_att)
get_wavg_ht = lambda g: np.average(g['HT'], weights=g['Calls'])
grouped.apply(get_wavg_ht)
get_wavg_acw = lambda g: np.average(g['ACW'], weights=g['Calls'])
grouped.apply(get_wavg_acw)