"No numeric types to aggregate" after groupby and mean
your data1
is of object
(string) dtype:
In [396]: datedatF.dtypes
Out[396]:
data1 object # <--- NOTE!
key1 datetime64[ns]
key2 int64
dtype: object
so try this:
In [397]: datedatF.assign(data1=pd.to_numeric(datedatF['data1'], errors='coerce')) \
.groupby('key2')['data1'].mean()
Out[397]:
key2
2015001 1.3
Name: data1, dtype: float64
You data1 type in your df is object , we need adding pd.to_numeric
datedatF.dtypes
Out[39]:
data1 object
key1 datetime64[ns]
key2 int64
dtype: object
grouped2=pd.to_numeric(datedatF['data1']).groupby(datedatF['key2'])
grouped2.mean()
Out[41]:
key2
2015001 1.3
Name: data1, dtype: float64