I have a csv file containing some float data. the code is simple
df = pd.read_csv(my_csv_vile)
print(df.iloc[:2,:4]
600663.XSHG 000877.XSHE 600523.XSHG 601311.XSHG
2016-01-04 09:31:00 49.40 8.05 22.79 21.80
2016-01-04 09:32:00 49.55 8.03 22.79 21.75
then I convert it to float32 to save memory usage.
short_df = df.astype(np.float32)
print(short_df.iloc[:2,:4])
600663.XSHG 000877.XSHE 600523.XSHG 601311.XSHG
2016-01-04 09:31:00 49.400002 8.05 22.790001 21.799999
2016-01-04 09:32:00 49.549999 8.03 22.790001 21.750000
the value just changed! How could I keep the data unchanged?
(I also tried short_df.round(2)
,but print still get the same output)