Python Pandas-合并列在to_html输出中显示为单独的列

Python Pandas-合并列在to_html输出中显示为单独的列,python,python-3.x,pandas,Python,Python 3.x,Pandas,我正在使用html转换从谷歌电子表格创建的数据框。在电子表格中,12列已合并为一列monthwise\u breakup。但是在html输出中,这些合并的列显示为12个单独的列 service = build('sheets', 'v4', credentials=creds) # Call the Sheets API sheet = service.spreadsheets() result_input = sheet.values().get(spreadsheetId=SAMPLE_S

我正在使用html转换从谷歌电子表格创建的数据框。在电子表格中,12列已合并为一列monthwise\u breakup。但是在html输出中,这些合并的列显示为12个单独的列

service = build('sheets', 'v4', credentials=creds)

# Call the Sheets API
sheet = service.spreadsheets()
result_input = sheet.values().get(spreadsheetId=SAMPLE_SPREADSHEET_ID_input,
                            range=SAMPLE_RANGE_NAME).execute()
values_input = result_input.get('values', [])
df=pd.DataFrame(values_input)
print(df.to_html(index=False))
电子表格

HTML输出


只有google工作表中的标题行被合并,标题下的列没有合并,因此它们应该是单独的列。看起来您想要的是在数据集中的列上建立一个多索引。如果您需要代码方面的帮助,请发布一个结果输入dict的示例。