python - In Pandas, how to re-determine the dtypes of columns after dropna? -


i have dataframe df constructed via read_csv. want compute statistics on sampled sub_df. sub_df, want drop rows missing nans , re-check true types of columns.

in data, many of integer columns read float because of missing values.

i think understand question. don't think can automatically, can manually convert datatype of column using astype:

import pandas pd import numpy np df = pd.dataframe([np.nan,2,3],columns = ['value']) df.dtypes value    float64 dtype: object  sub_df = df[df.value.notnull()] sub_df.value = sub_df.value.astype(int) sub_df.dtypes value    int32 dtype: object 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -