简体   繁体   中英

Pivot/Unstack Pandas Dataframe Data

Grateful for your help. Sorry, could not figure this out as I wasn't sure if I'm pivoting or unstacking.

My data looks like this:

Email Col1 Col2 Col3
si@si A 2 D
ad@ad A 5 C

I'm looking to pivot this to:

si@si ad@ad
Col1 A A
Col2 2 5
Col3 D C

Thanks so much!

Transpose the dataFrame.

df.set_index('Email').rename_axis(None).T

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM