I am trying to import an Excel file with several sheets containing the same structure of bidimensional arrays in a multi-indexed Dataframe in Python.
Assume each sheet contains an array (A,B)x(a,b). Basically I would like to have something like this
Sheet1 | Sheet2 | Sheet3
a | b | a | b | a | b
A
B
I have tried to use a for loop.
df={}
for i in Sheets:
df[i] = pd.read_excel (r'file.xlsx', sheet_name = [i], header=0, index_col=0)
I would expect df to be such that, if I recall
df['Sheet1']
I can retrieve one of the arrays, and this actually works fine. The problem comes up if I try to recall
df['Sheet1']['a']
to retrieve the first column of the first sheet. However, I get the following error message
KeyError: a
and I am stuck here.