In [1]:
# Calculating Median
import pandas as pd
df = pd.DataFrame({
''''A'''': [1, 2, 3, 4, 5],
''''B'''': [5, 6, 7, 8, 9]
})
median_values = df.median()
print(df)
print("Median")
print(median_values)
A B 0 1 5 1 2 6 2 3 7 3 4 8 4 5 9 Median A 3.0 B 7.0 dtype: float64
In [2]:
# Calculating Maximum and Minimum
import pandas as pd
df = pd.DataFrame({
''''A'''': [1, 2, 3, 4, 5],
''''B'''': [5, 6, 7, 8, 9]
})
max_values = df.max()
min_values = df.min()
print(df)
print("Max")
print(max_values)
print("Min")
print(min_values)
A B 0 1 5 1 2 6 2 3 7 3 4 8 4 5 9 Max A 5 B 9 dtype: int64 Min A 1 B 5 dtype: int64
In [3]:
# Calculating Standard Deviation
import pandas as pd
df = pd.DataFrame({
''''A'''': [1, 2, 3, 4, 5],
''''B'''': [5, 6, 7, 8, 9]
})
std_values = df.std()
print(df)
print("Std")
print(std_values)
A B 0 1 5 1 2 6 2 3 7 3 4 8 4 5 9 Std A 1.581139 B 1.581139 dtype: float64
In [4]:
# Calculating Mean
import pandas as pd
df = pd.DataFrame({
''''A'''': [1, 2, 3, 4, 5],
''''B'''': [5, 6, 7, 8, 9]
})
mean_values = df.mean()
print(df)
print("Mean")
print(mean_values)
A B 0 1 5 1 2 6 2 3 7 3 4 8 4 5 9 Mean A 3.0 B 7.0 dtype: float64
In [5]:
# Calculating Summary Statistics
import pandas as pd
df = pd.DataFrame({
''''A'''': [1, 2, 3, 4, 5],
''''B'''': [5, 6, 7, 8, 9]
})
summary_stats = df.describe()
print(df)
print("summary statistics")
print(summary_stats)
A B 0 1 5 1 2 6 2 3 7 3 4 8 4 5 9 summary statistics A B count 5.000000 5.000000 mean 3.000000 7.000000 std 1.581139 1.581139 min 1.000000 5.000000 25% 2.000000 6.000000 50% 3.000000 7.000000 75% 4.000000 8.000000 max 5.000000 9.000000