Statistics with Panda DataFrame

Below are the Pandas DataFrame statistical methods with their description:

MethodDescriptionExample
describeThis method returns a small table with descriptive statistics
print("Describe", sunspots.describe(),"\n")

#out
Describe        Yearly Mean Total Sunspot Number  Yearly Mean Standard Deviation  \
count                        317.000000                      199.000000   
mean                          79.378233                        8.009548   
std                           61.998961                        3.808942   
min                            0.000000                        1.700000   
25%                           25.100000                        4.700000   
50%                           66.700000                        7.700000   
75%                          116.300000                       10.450000   
max                          269.300000                       19.100000   

       Number of Observations  Definitive/Provisional Indicator  
count              199.000000                             317.0  
mean              1467.678392                               1.0  
std               2463.925956                               0.0  
min                150.000000                               1.0  
25%                365.000000                               1.0  
50%                365.000000                               1.0  
75%                366.000000                               1.0  
max               9940.000000                               1.0
countThis method returns the number of non-NaN items
print("Non NaN observations", sunspots.count(),"\n")

#out
Non NaN observations Yearly Mean Total Sunspot Number    317
Yearly Mean Standard Deviation      199
Number of Observations              199
Definitive/Provisional Indicator    317
dtype: int64
madThis method calculates the mean absolute deviation, which is a robust measure similar to the standard deviation
print("MAD", sunspots.mad(),"\n")

#out
MAD Yearly Mean Total Sunspot Number      50.931061
Yearly Mean Standard Deviation         3.128860
Number of Observations              1838.628924
Definitive/Provisional Indicator       0.000000
dtype: float64
medianThis method returns the median. This is equivalent to the value at the 50th percentile
print("Median", sunspots.median(),"\n")

#out
Median Yearly Mean Total Sunspot Number     66.7
Yearly Mean Standard Deviation        7.7
Number of Observations              365.0
Definitive/Provisional Indicator      1.0
dtype: float64
minThis method returns the lowest value
print("Min", sunspots.min(),"\n")

#out
Min Yearly Mean Total Sunspot Number      0.0
Yearly Mean Standard Deviation        1.7
Number of Observations              150.0
Definitive/Provisional Indicator      1.0
dtype: float64
maxThis method returns the highest value
print("Max",	sunspots.max(),"\n")

#out
Max Yearly Mean Total Sunspot Number     269.3
Yearly Mean Standard Deviation        19.1
Number of Observations              9940.0
Definitive/Provisional Indicator       1.0
dtype: float64
modeThis method returns the mode, which is the most frequently occurring value
print("Mode",	sunspots.mode(),"\n")

#out
Mode    Yearly Mean Total Sunspot Number  Yearly Mean Standard Deviation  \
0                              18.3                             9.2   

   Number of Observations  Definitive/Provisional Indicator  
0                   365.0                               1.0
stdThis method returns the standard deviation, which measures dispersion. It is the square root of the variance
print("Standard Deviation", sunspots.std(),"\n")

#out
Standard Deviation Yearly Mean Total Sunspot Number      61.998961
Yearly Mean Standard Deviation         3.808942
Number of Observations              2463.925956
Definitive/Provisional Indicator       0.000000
dtype: float64
varThis method returns the variance
print("Variance", sunspots.var(),"\n")

#out
Variance Yearly Mean Total Sunspot Number    3.843871e+03
Yearly Mean Standard Deviation      1.450804e+01
Number of Observations              6.070931e+06
Definitive/Provisional Indicator    0.000000e+00
dtype: float64
skewThis method returns skewness. Skewness is indicative of the distribution symmetry
print("Skewness", sunspots.skew(),"\n")

#out
Skewness Yearly Mean Total Sunspot Number    0.804414
Yearly Mean Standard Deviation      0.561530
Number of Observations              1.871952
Definitive/Provisional Indicator    0.000000
dtype: float64
kurtThis method returns kurtosis. Kurtosis is indicative of the distribution shape
print("Kurtosis", sunspots.kurt(),"\n")

#out
Kurtosis Yearly Mean Total Sunspot Number   -0.135040
Yearly Mean Standard Deviation     -0.243958
Number of Observations              1.850223
Definitive/Provisional Indicator    0.000000
dtype: float64

Leave a Reply