df.describe() does not show all stats for columns of large numbers

Viewed 2390

I'm trying to generate statistics (among other things) for a list of bignums, but it doesn't work.

import pandas as pd

# example numbers
dataset = pd.DataFrame(data=[2 ** 64, 2 ** 65, 2 ** 66], columns=['bignum'])
print(dataset.describe())

It prints the following, but not the statistics I wanted, like standard deviation, mean, etc, like it does with lists of smaller numbers.

                      bignum
count                      3
unique                     3
top     36893488147419103232
freq                       1

I'd like it to say something like this:

       bignum
mean      ...
std       ...
min       ...
25%       ...
50%       ...
75%       ...
max       ...
1 Answers
dataset.dtypes

bignum    object
dtype: object

For some reason, your column is loaded into pandas as an object. The solution is:

dataset.astype(float).describe()

             bignum
count  3.000000e+00
mean   4.304240e+19
std    2.817787e+19
min    1.844674e+19
25%    2.767012e+19
50%    3.689349e+19
75%    5.534023e+19
max    7.378698e+19

Cast the column to float to see the statistics you wanted.

Related