python - Pandas max() and min() work but mean() gives "No numeric types" errror -


i'm having difficulties following pandas code:

groupby_obj = features.groupby('feature') print groupby_obj["value"].max() # works print groupby_obj["value"].min() # works print groupby_obj["value"].mean() #this doesn't work 

the third line gives following error:

dataerror: no numeric types aggregate 

this looks same error this answer isn't easy follow. using frame.astype(float) won't work me because of columns strings. features[['value']] = features[['value']].astype(float) seems messy (and involves unnecessary copy operation).

is there way specify types columns when dataframe instantiated? or different way achieve i'm trying do?

as min/max issue, think strings. can have min/max string (in lowercase alphabet, 'a' , 'z' respectively), mean string makes no sense.

also, try casting particular column (value) float , math.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -