我有12个相同形状的数据帧,用于12年的数据收集。我需要使用这个面板来绘制时间序列轴(年)上的各种列值。因此,我认为我应该将这些框架作为面板对齐。在
一些示例数据:
# for 2015
Grave Crimes Cases Recorded Mistake of Law fact
Abduction 725 3
Kidnapping 246 6
Arson 466 1
Mischief 436 1
House Breaking 12707 21
Grievous Hurt 1299 3
# for 2016
Grave Crimes Cases Recorded Mistake of Law fact
Abduction 738 4
Kidnapping 297 9
Arson 486 4
Mischief 394 1
House Breaking 10287 14
Grievous Hurt 1205 0
# for 2017
Grave Crimes Cases Recorded Mistake of Law fact
Abduction 647 2
Kidnapping 251 10
Arson 418 3
Mischief 424 0
House Breaking 8913 12
Grievous Hurt 1075 1
假设数据帧的名称类似于df15、df16、df17,则可以使用它们创建面板,如:
之后,你可以用下面的方法做你在问题中提到的3D绘图:
^{pr2}$但是,如果我可以从我自己的经验中给你一个关于可读性好的数据可视化的提示,我想许多专业人士会分享:
即使一个数据集是3维或更高维的结构,创建一个设计良好的二维图通常也是一个不错的选择。3D通常会吸引眼球,但为了告知目标受众并显示数据的某些属性,您几乎可以使用2d。考虑到这一点,Ami Tavory的方法将是更好的方法,因为数据结构更易于处理:
虽然面板允许添加维度,但层次索引是一种更常见的替代方法。E、 g.,来自Python Data Science Handbook:
对你来说
假设您的数据帧位于}。您可以执行以下操作:
df_2015
、df_2016
和{现在要获得
^{pr2}$'Abduction'
所有年份的数据,例如,使用相关问题 更多 >
编程相关推荐