python - Python - 加载具有多个标题的数据框
问题描述
我有一个数据集,其中包含不同整流器的电压和电流输出。这些值通常每两个月测量一次,因此它们具有对应的日期。目前我所做的是为每个整流器制作了一个单独的数据框,并制作了一个数据框字典。之后,我被困在如何绘制日期与电压/安培的关系上。有没有更简单的方法可以做到这一点,我可能会错过?以下是数据示例以及我的代码。
1/1/2015 2/1/2015 3/1/2015
Rectifier Volts Amps Volts Amps Volts Amps
9E220ECP5001 11.10 31.95 11.30 31.05
9E220ECP5002 19.30 62.60 13.10 39.60
9E220ECP5003 4.50 6.30 4.60 6.30
9E220ECP5004 4.40 8.40 4.60 8.55
9E220ECP5005 20.90 41.40 17.60 32.07
9E220ECP5006 35.10 7.84 31.90 6.40
9E220ECP5007 13.50 22.72 17.30 29.12
9E220ECP5008 4.50 6.15 5.00 6.15
https://imgur.com/a/RJgtMWf
import pandas as pd
df = pd.read_excel("Rectifier_DB.xlsx", header = [0,1], index_col=0)
rectifiers = list(df.index.values)
rect_dict = {}
for index, rect in enumerate(rectifiers):
rect_dict[rect] = pd.DataFrame(df.iloc[index])
解决方案
您可能需要定义索引列:
df = pd.read_excel('Rectifier_DB.xlsx', header=[0, 1], index_col=0)
推荐阅读
- vba - VBA Word 中的空白选定文本将显示为 2 个字符
- python - 是否有任何用于 Python 的 API 以 JSON 格式返回翻译?
- javascript - Git 分支最佳实践 - 大师、生产、登台?
- android - RxJava retryWhen 更新值 + 并发
- spring-boot - 为什么休眠会抛出constraintViolationException?
- javascript - Lazyload 不适用于无限滚动 - Ruby on Rails
- bots - Gupshup whatsapp bot 估计的实施时间
- c# - 如何在 Unity 中控制点光源的颜色?
- teradata - 在 teradata sql 中将多行连接成一列
- netty - 可以检测一个连接是来自 netty 库,还是只是一个普通的套接字?