I have this dataframe:
pd.DataFrame({"X": [1,2,3,4],
"Y": [5,6,7,8],
"Z": [9,10,11,12]})
And I'm looking for this output:
Currently, the similar problems solved I have found are the opposite: looking from series to dataframe. The most similar I have found is this one, which isn't similar at all. I have tried also with pivot_table()
and reshape()
, but they require an index column where I'm just looking for one column.
Any suggestions?
PS: You can assume that the dataframe has 100 columns to avoid selecting them one by one, but you call them as they are ordered (e.g. if they are 100 columns, you can do X1:X100
)