Loading…
DS · Data basics · Program 03 · In the record
Descriptive statistics: mean, median, mode, variance, std dev, covariance.
1import pandas as pd2 3df = pd.DataFrame({'A': [10, 20, 20, 30, 40, 50], 'B': [15, 25, 25, 35, 45, 55]})4 5print("Mean:\n", df.mean())6print("\nMedian:\n", df.median())7print("\nMode:\n", df.mode())8print("\nVariance:\n", df.var())9print("\nStandard Deviation:\n", df.std())10print("\nCovariance:\n", df.cov())Mean:
A 28.333333
B 33.333333
dtype: float64
Median:
A 25.0
B 30.0
dtype: float64
Mode:
A B
0 20 25
Variance:
A 216.666667
B 216.666667
dtype: float64
Standard Deviation:
A 14.719601
B 14.719601
dtype: float64
Covariance:
A B
A 216.666667 216.666667
B 216.666667 216.666667Run program 03 in your browser
Python 3.14 · Pyodide. Change the code or the input, run it, break it, and see what happens.