系列描述绘图功能

2024-09-27 00:13:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我有个问题要问你。在熊猫系列中,哪一个图最能显示结果

filter = genderage['Customer_Gender'] == "F"
genderage[filter]
genderage[filter].describe()

    Customer_Age
count   54724.000000
mean    36.168993
std 10.910622
min 17.000000
25% 28.000000
50% 35.000000
75% 43.000000
max 87.000000

Tags: agecountcustomerfilterminmeangendermax
1条回答
网友
1楼 · 发布于 2024-09-27 00:13:28

一个boxplot将几乎所有这些信息组合成一个单一的可视化。默认情况下,它不会绘制mean,但您可以将其添加为带有meanlineshowmeans的虚线

晶须从maxmin伸出。虚线是平均值。方框从25%延伸到75%,方框中的实线为中值(50%)。您只是错过了标准偏差和计数,如果需要,可以将其添加为文本

import numpy as np
import pandas as pd

np.random.seed(123)
s = pd.Series(np.random.chisquare(34, 100))

s.describe()
#count    100.000000
#mean      34.674010
#std        8.393988
#min       15.306646
#25%       29.043357
#50%       33.556184
#75%       40.380201
#max       56.930963
#dtype: float64

s.to_frame('data').boxplot(meanline=True, showmeans=True)

enter image description here

相关问题 更多 >

    热门问题