Super newbie Python/Pandas question.
I am trying to read a folder of Excel workbooks with multiple sheets, extract the column headers as a list, and add each list as a new column in a pandas DataFrame. Here's the code I have so far:
import pandas as pd
import numpy as np
filepath = '/content/data.xlsx'
workbook = pd.read_excel(filepath, None, nrows=0)
variables_frame = []
for sheet_name, sheet in workbook.items():
variables = sheet.columns
variables_list = list(variables)
variables_frame = pd.DataFrame.insert(sheet+1, sheet_name, [variables_list])
print(variables_frame)
However, I get the error "TypeError: insert() missing 1 required positional argument: 'value'" when I try to run this. Any ideas why?
Additionally, if this is not the right way to go about this I'd appreciate any more general feedback. Thank you!