Pandas DataFrame Pivot, reset index
I have a data-frame which looks in as simplified way like following: import pandas as pd df = pd.DataFrame({ 'catYM': [202601,202601,202602,202603,202603,202501,202501], 'prod': [20,26,34,45,18,19,20]}) print(df) catYM prod 0 202601 20 1 202601 26 2 202602 34 3 202603 45 4 202603 18 5 202501 19 6 202501 20 The data-frame has a total length of m= index+1 rows. The column catYM defines the categories with respective values in column prod. The number of rows per category varies. I could have n categories. When using df.pivot I see a new data-frame with n columns and m rows with a lot of NaN fille
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.