Planets - DataFrame Statistics



examples/pandas/dataframe_stats.py
import sys
import pandas as pd

filename = "planets.csv"
if len(sys.argv) == 2:
    filename = sys.argv[1]

df = pd.read_csv(filename)

print(df.columns)
print()

print(df.dtypes)
print()

print(df.index)
print()

print(df.values)
print()

print(df.describe())

Index(['Planet name', 'Distance (AU)', 'Mass'], dtype='object')

Planet name       object
Distance (AU)    float64
Mass             float64
dtype: object

RangeIndex(start=0, stop=11, step=1)

[['Mercury' 0.4 0.055]
 ['Venus' 0.7 0.815]
 ['Earth' 1.0 1.0]
 ['Mars' 1.5 0.107]
 ['Ceres' 2.77 0.00015]
 ['Jupiter' 5.2 318.0]
 ['Saturn' 9.5 95.0]
 ['Uranus' 19.6 14.0]
 ['Neptune' 30.0 17.0]
 ['Pluto' 39.0 0.00218]
 ['Charon' 39.0 0.000254]]

       Distance (AU)        Mass
count      11.000000   11.000000
mean       13.515455   40.543599
std        15.638671   96.205021
min         0.400000    0.000150
25%         1.250000    0.028590
50%         5.200000    0.815000
75%        24.800000   15.500000
max        39.000000  318.000000