Igor K.
Igor K.

Reputation: 877

Disable rounding in mean function

My DataFrame:

               Date      Value       Mean
2020-01-01 19:00:00  238.83298   0.028021
2020-01-01 20:00:00  238.86101   0.028022
2020-01-01 21:00:00  238.88903   0.028022
2020-01-01 22:00:00  238.91706   0.028022
2020-01-01 23:00:00  238.94509   0.028023
2020-01-02 00:00:00  238.97312   0.028024

This is how column Mean was calculated:

df_ephe['Mean'] = df['Value'].rolling(24).mean()

But it is rounded to 6 digits after point.
I don't need rounding at all.
How to get full length of Mean?
I haven't found any options in rolling() or mean() functions to do it.

Upvotes: 0

Views: 135

Answers (1)

Sajad.sni
Sajad.sni

Reputation: 318

The default precision to display in pandas is 6 digits. the real precision of computing is based on the data type itself.(e.g. np.float32 or np.float64)

>>df = pd.DataFrame({'just_a_number': [1.1234567890]})
>>df.head()
>>   just_a_number
0       1.123457

Changing display precision:

>>pd.set_option("display.precision", 10)
>>df.head()
>>   just_a_number
0    1.123456789

Upvotes: 1

Related Questions