I'm trying to plot a DataFrame
using pandas
but it's not working (see this similar thread for details). I think part of the problem might be that my DataFrame
seems to be made of objects
:
>>> df.dtypes
Field object
Moment object
Temperature object
However, if I were to convert all the values to type float
, I lose a lot of precision. All the values in column Moment are of the form -132.2036E-06
and converting to float
with df1 = df.astype(float)
changes it to -0.000132
.
Anyone know how I can preserve the precision?
You can do this to change the displayed precision
In [1]: df = DataFrame(np.random.randn(5,2))
In [2]: df
Out[2]:
0 1
0 0.943371 0.171686
1 1.508525 0.005589
2 -0.764565 0.259490
3 -1.059662 -0.837602
4 0.561804 -0.592487
[5 rows x 2 columns]
In [3]: pd.set_option('display.precision',12)
In [4]: df
Out[4]:
0 1
0 0.94337126946 0.17168604324
1 1.50852519105 0.00558907755
2 -0.76456509501 0.25948965731
3 -1.05966206139 -0.83760201886
4 0.56180449801 -0.59248656304
[5 rows x 2 columns]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With