python - save pandas data frame as 32-bit float -


i have data in pandas i'm trying save 32-bit float instead i'm getting 64-bit float. best attempt this:

df['store'] = pd.dataframe(data).astype(float32)  

but it's not working.. ideas?

use numpy.float32:

in [320]: import numpy np import pandas pd df = pd.dataframe({'a':np.random.randn(10)}) df.info()  <class 'pandas.core.frame.dataframe'> int64index: 10 entries, 0 9 data columns (total 1 columns):    10 non-null float64 dtypes: float64(1) memory usage: 160.0 bytes  in [323]:    df['a'].astype(np.float32)  out[323]: 0    0.966618 1   -0.331942 2    0.906349 3   -0.089582 4   -0.722004 5    0.668103 6    0.230314 7   -1.707631 8    1.806862 9    1.783765 name: a, dtype: float32 

you can see dtype float32


Comments