统计 iris 各列属性均值,方差,标准差,中位数并打印输出。
时间: 2023-05-21 16:05:42 浏览: 127
可以使用Python中的pandas库来完成这个任务。代码如下:
```python
import pandas as pd
# 读入iris数据集
iris = pd.read_csv('iris.csv')
# 统计各列均值
means = iris.mean()
print('各列均值:\n', means)
# 统计各列方差
variances = iris.var()
print('各列方差:\n', variances)
# 统计各列标准差
stds = iris.std()
print('各列标准差:\n', stds)
# 统计各列中位数
medians = iris.median()
print('各列中位数:\n', medians)
```
输出结果如下:
```
各列均值:
sepal_length 5.843333
sepal_width 3.054000
petal_length 3.758667
petal_width 1.198667
dtype: float64
各列方差:
sepal_length 0.685694
sepal_width 0.188004
petal_length 3.113179
petal_width 0.582414
dtype: float64
各列标准差:
sepal_length 0.828066
sepal_width 0.433594
petal_length 1.764420
petal_width 0.763161
dtype: float64
各列中位数:
sepal_length 5.8
sepal_width 3.0
petal_length 4.35
petal_width 1.3
dtype: float64
```