汇总时间序列数据的取值

用 Python 可视化时间序列数据

Thomas Vincent

Head of Data Science, Getty Images

获取数据的数值摘要

  • 此数据的平均值是多少?
  • 该时间序列的最大值是多少?
用 Python 可视化时间序列数据

.describe() 方法会自动计算 DataFrame 中所有数值列的关键统计量

print(df.describe())
               co2
count  2284.000000
mean    339.657750
std      17.100899
min     313.000000
25%     323.975000
50%     337.700000
75%     354.500000
max     373.900000
用 Python 可视化时间序列数据

用箱线图汇总数据

ax1 = df.boxplot()
ax1.set_xlabel('Your first boxplot')
ax1.set_ylabel('Values of your data')
ax1.set_title('Boxplot values of your data')

plt.show()
用 Python 可视化时间序列数据

CO2 数据取值的箱线图

时间序列的箱线图

用 Python 可视化时间序列数据

用直方图汇总数据

ax2 = df.plot(kind='hist', bins=100)
ax2.set_xlabel('Your first histogram')
ax2.set_ylabel('Frequency of values in your data')
ax2.set_title('Histogram of your data with 100 bins')

plt.show()
用 Python 可视化时间序列数据

CO2 数据取值的直方图

含 100 个柱的直方图

用 Python 可视化时间序列数据

用密度图汇总数据

ax3 = df.plot(kind='density', linewidth=2)
ax3.set_xlabel('Your first density plot')
ax3.set_ylabel('Density values of your data')
ax3.set_title('Density plot of your data')

plt.show()
用 Python 可视化时间序列数据

CO2 数据取值的密度图

数据的密度图

用 Python 可视化时间序列数据

Let's practice!

用 Python 可视化时间序列数据

Preparing Video For Download...