Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • I get index Date contains duplicate values error. How to handle that? Commented Nov 6, 2023 at 7:30
  • 1
    Please don't post pictures of data (the example input and output). Instead, you can use print(df) and put it in code formatting or print(df.to_markdown()) which gives you table formatting. Commented Jul 2 at 14:40
  • Why are you doing pivot_df.columns = df['Country'].sort_values().unique()? That happens automatically. Effectively all that's doing is removing the axis name, i.e. pivot_df.columns.name = None. Commented Jul 2 at 15:29
  • 1
    Also, why are you using pd.pivot(df, ...) instead of the shorter df.pivot(...)? Commented Jul 2 at 15:31