将 Excel 中的列与 Pandas 混合为一列
我必须在代码中导入此Excel,并且想在单列中统一多指数。我想删除未透露姓名的列,并将所有内容统一成一个。我不知道是否可能。
我尝试了以下内容,并且它导入了以下内容,但是输出不太预期。我在这里也添加代码
import pandas as pd
import numpy as np
macro = pd.read_excel(nameExcel, sheet_name=nameSheet, skiprows=3, header=[1,3,4])
macro = macro[macro.columns[1:]]
macro
I have to import this Excel in code and I would like to unify the multi-index in a single column. I would like to delete the unnamed columns and unify everything into one. I don't know if it's possible.
I have tried the following and it imports, but the output is not as expected. I add the code here too
import pandas as pd
import numpy as np
macro = pd.read_excel(nameExcel, sheet_name=nameSheet, skiprows=3, header=[1,3,4])
macro = macro[macro.columns[1:]]
macro
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决的方法是保存另一个与前一个 header 长度相同的 header。
The way to solve it is to save another header of the same length as the previous header.