python - 熊猫:从excel中拆分合并的标题
问题描述
我有一个像这样合并标题的excel文件
我想要的是使用熊猫这样的标题
我尝试使用此解决方案: https ://stackoverflow.com/a/27424102/12934577
但它回来了
sequence item 0: expected str instance, float found
解决方案
您可能需要str
像在那个答案中那样使用:
df.columns = df.iloc[0:2].apply(lambda x: '.'.join([str(y) for y in x if y]), axis=0)
推荐阅读
- mysql - SQL - 获取具有一个结果和选定选项的行 - 关系表
- python - 从 SQL 输出表为 csv 格式并在列周围添加引号
- sql - Oracle 到 SQL Server 迁移中的外键错误
- reactjs - 向用户显示“For”循环的状态
- powerbi - Power BI if condition if true then column with date value else NULL
- c++ - 从一系列字符构造 string_view
- python-3.x - 根据另一列的对应行重命名一列的行
- jasper-reports - Jasper Json 嵌套列表
- google-cloud-platform - 如何将持久存储挂载到 Google Cloud Run?
- tableau-api - 混合数据源