Last active
May 18, 2020 01:51
-
-
Save hauselin/c21dc322c67549afed56e2ccd6500d50 to your computer and use it in GitHub Desktop.
pandas long
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df_long = pd.DataFrame( | |
{"student": ["Andy", "Bernie", "Cindy", "Deb", "Andy", "Bernie", "Cindy", "Deb", "Andy", "Bernie", "Cindy", "Deb"], | |
"school": ["Z", "Y", "Z", "Y", "Z", "Y", "Z", "Y", "Z", "Y", "Z", "Y"], | |
"class": ["english", "english", "english", "english", "math", "math", "math", "math", "physics", "physics", "physics", "physics"], | |
"grade": [10, 100, 1000, 10000, 20, 200, 2000, 20000, 30, 300, 3000, 30000] | |
} | |
) | |
df_long | |
> student school class grade | |
0 Andy Z english 10 | |
1 Bernie Y english 100 | |
2 Cindy Z english 1000 | |
3 Deb Y english 10000 | |
4 Andy Z math 20 | |
5 Bernie Y math 200 | |
6 Cindy Z math 2000 | |
7 Deb Y math 20000 | |
8 Andy Z physics 30 | |
9 Bernie Y physics 300 | |
10 Cindy Z physics 3000 | |
11 Deb Y physics 30000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment