我正在尝试将此多索引数据帧转换为单个索引数据帧以划分两个单索引数据帧
第一个数据框 这是我尝试用来划分的第一个数据框。
import pandas as pd
data = {'Sensor':[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], 1 :[100, 103.078, 103.078, 79.0569, 55.9017, 25, 25, 25, 50, 50, 106.066, 125, 125], 3 :[25, 50, 50, 90.1388, 106.066, 125, 125, 100, 103.078, 103.078, 55.9017, 25, 25]}
dfDistance = pd.DataFrame(data)
dfDistance
我有第二个多索引数据框,其中的数据大小相同。但由于一个是多索引,另一个只是单个索引,因此在划分它们时会引起问题。有没有办法可以将两者分开,或者我是否需要从多索引中提取数据并从中构建单个索引?抱歉,如果这篇文章的格式不好,这是我第一次使用堆栈溢出。 这是我的多索引数据框,它是从 .csv 生成的,经过很多调整
我的预期输出应该是这样的,没有所有 NaN,第 13 行应该是 .032 和 .356 输出混乱的数据
First Data Frame This is the first data frame that I am trying to use to divide.
import pandas as pd
data = {'Sensor':[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], 1 :[100, 103.078, 103.078, 79.0569, 55.9017, 25, 25, 25, 50, 50, 106.066, 125, 125], 3 :[25, 50, 50, 90.1388, 106.066, 125, 125, 100, 103.078, 103.078, 55.9017, 25, 25]}
dfDistance = pd.DataFrame(data)
dfDistance
And I have a second multi-index data frame that has data in it that is the same size. But since one is multi-index and the other is just a single index it is causing issues when dividing them. Is there a way I can divide the two or do I need to rip the data from the multi-index and build a single index out of it? Sorry if this post is poorly formatted this is my first time using stack overflow.
Here is my multi-index dataframe it is generated from a .csv with lots of tweaks
My expected output should be something like this without all the NaNs and row 13 should be .032 and .356 Output data that is messed up
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论