I am looking forward to groupby the columns in a df and I had to look to this post pandas groupby dropping columns because in my case I am also loosing columns when group_by().mean() and I tried to do a
df.groupby("A", as_index=False).mean()
and a
df.groupby('A').mean().reset_index()
Then I checked the columns in my df and found out 3 of the columns are object type with
df.types
The issue i have is that i am unable to change the columns type from object to float64 ( which are by the way the columns that dissapear after the groupby
what i tried to change my columns is:
df['A']=df['A'].astype(float)
df['A']=df['A'].astype(np.float64)
df.convert_objects(convert_numeric=True)
pd.to_numeric(df, errors='coerce')
But did not worked either
But the columns continue to be object type.
It is complex to replicate my df with the dtypes of the columns, but I will post the df used for this case.
My df:
df=pd.DataFrame(data=np.transpose([[1.014e-7,0,3,1.014e-7],[2,4,6,8],[1,1,1,1],[5,5,5,8]]),index=['x','y','w','z'],columns=['A','B','C','D'])