I want transform column data to rows like this,how could I perform this?programming language is python
original data:
data month user_id
0 3782.0 01 1
1 1882.0 02 1
2 536.0 03 2
3 526.0 04 2
transformed data:
user_id mo_1 mo_2 mo_3 mo_4
1 3782 1882
2 536 526
original data definition:
df = pd.DataFrame({'user_id': {0: 1, 1: 1, 2: 1, 3: 1},
'month': {0: '01', 1: '02', 2: '03', 3: '04'},
'data': {0: 3782., 1: 1882., 2: 536., 3: 526.},})