Considering the following dataframe:
import pandas as pd
import numpy as np
import random
np.random.seed(10)
df1 = pd.DataFrame({'x':[1,2,3,4,5,1,2,3,4,5],
'y':[10,10,10,10,10,20,20,20,20,20],
'z':np.random.normal(size = 10)
})
I want to convert the x
values into columns and y
values into index (decreasing) with corresponding z values in the dataframe. It's something like this df2:
df2 = pd.DataFrame(np.random.randn(2,5), index = [20,10], columns=[1,2,3,4,5])
How can I conver df1
into df2
's style?