-
Notifications
You must be signed in to change notification settings - Fork 96
Closed
Description
I was testing the following piece of Python3 code:
df = pd.DataFrame({'idx': ['A', 'B', 'C', 'D'],
'quantity': [3, 4, 10, 11]})
def split_quant(df):
quantities = ([4]*(df['quantity'].iat[0] // 4)) + [df['quantity'].iat[0] % 4]
temp = pd.DataFrame({'idx': df['idx'].iat[0],
'quantity': quantities
}, index=range(len(quantities)))
return temp
df_split = df[df['quantity'] > 4].groupby('idx').apply(split_quant)
output = df[df['quantity'] <= 4].append(df_split).reset_index(drop=True)
The variable inspector correctly lists 3 dataframes. df
and output
correctly open in new windows when theirs names are clicked. However I get an error when I click on df_split
In dev tools I see the following error:
Uncaught (in promise) Kernel error on 'matrixQuery' call!
Promise.then (async)
row.onclick @ variableinspector.js:97
Seems its a ValueError
where the message is "Overlapping names between the index and columns"
When I call print(df_split)
I see that the dataframe looks like this:
idx quantity
idx
C 0 C 4
1 C 4
2 C 2
D 0 D 4
1 D 4
2 D 3
So the overlapping names error makes sense, but more generally, whats the plan for handling hierarchical/multi index dataframes?
JarnoRFB
Metadata
Metadata
Assignees
Labels
No labels