'Create new column for each unique value in other column in pandas dataframe
In my dataset I have value for each region(West, South, East and Central) at the start of each month from 2015-2018.
I need to transform the dataset in the next way: I want to create columns for each region remove column "Value": Datetime Central West East South 2015-01-01 0.1 0.2 0.3 0.4
How can I do it?Dataset
Solution 1:[1]
You can try df.pivot
df.pivot(index='Datetime', columns='Region', values='Value').reset_index()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ynjxsjmh |
