如何从大约有200个国家的数据集中生成一个干净的时间序列?

2024-06-17 15:50:33 发布

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

这是我正在使用的数据集(以下文本版本): enter image description here

我试图制作一个时间序列图,显示一个国家在一段时间内的表现。我用熊猫为每场比赛添加了新的栏,无论是主场还是客场。然后,我查看每个国家每年的总积分,以衡量一段时间内的绩效,并根据每年的积分绘制时间序列图。然而,问题是,自1872年以来,该数据集已经匹配了大约200个国家。因此,我的时间序列如下所示: enter image description here

我曾尝试使用df.resample并对数据帧进行重新采样以显示10年周期,但这不起作用,时间序列看起来很混乱。有没有人对我如何才能让这个时间序列变得清晰,从而展示一个国家在一段时间内的表现有什么建议

数据的文本版本:

date    home_team   away_team   home_score  away_score  tournament  city    country neutral total_goals points_home points_away
0   1872-11-30  Scotland    England 0   0   Friendly    Glasgow Scotland    False   0   1.0 1.0
1   1873-03-08  England Scotland    4   2   Friendly    London  England False   6   3.0 0.0
2   1874-03-07  Scotland    England 2   1   Friendly    Glasgow Scotland    False   3   3.0 0.0
3   1875-03-06  England Scotland    2   2   Friendly    London  England False   4   1.0 1.0
4   1876-03-04  Scotland    England 3   0   Friendly    Glasgow Scotland    False   3   3.0 0.0
5   1876-03-25  Scotland    Wales   4   0   Friendly    Glasgow Scotland    False   4   3.0 0.0
6   1877-03-03  England Scotland    1   3   Friendly    London  England False   4   0.0 3.0

Tags: 数据文本版本falsehome时间序列国家