简体   繁体   English

结合具有不同时间间隔的两个数据帧

[英]Combining two dataframes with different time intervals

I am doing a study in school about the effect of noise in a person's environment and his/her activity.我正在学校研究噪音对一个人的环境和他/她的活动的影响。

I have two dataframes with data I would like to compare.我有两个数据框,其中包含我想比较的数据。 The data was recorded at the same time, but the time intervals between measurements are different.数据是同时记录的,但测量之间的时间间隔不同。 This makes it hard for me to overlay a plot and look at possible correlations.这让我很难覆盖一个情节并查看可能的相关性。

The data frames look like this:数据框如下所示:

Volume level:音量级别:

图像音量 df

steps:脚步:

图像步骤 df

When I try to put these two dataframes in one plot with a sync timeline, the steps graph looks way smaller than the volume level graph.当我尝试将这两个数据帧放在一个带有同步时间线的图中时,步骤图看起来比音量图小得多。 I have tried to plot the two graphs in multiple ways, but I keep ending up with something like this:我试图以多种方式绘制这两个图表,但我一直以这样的方式结束:

我最终的情节

How about this.这个怎么样。 This code uses multi y axis so it will help you with your problem that the graph size doesn't fit.此代码使用多 y 轴,因此它将帮助您解决图形大小不合适的问题。

ax = steps_Niels_1st["steps"].plot()
ax1 = ax.twinx()
ax = volume_data_Niels_1st['size'].plot(ax=ax1)
plt.show()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM