Home > Blockchain >  how to create basic level DataFrame by using dictionary
how to create basic level DataFrame by using dictionary

Time:05-29

I have a DataFrame like this

enter image description here

but I want to create DataFrame like this ;

enter image description here

Actually, I just want to append salary up to min, max and mean

CodePudding user response:

Try this

df = df.set_index('department_name')
# add salary as level=0 column name
df.columns = pd.MultiIndex.from_product([['salary'], df.columns])
  • Related