I want to use pandas datafaram to make a table such that x should be first column of my table,y should be second and z should be third. But I am getting ValueError: Shape of passed values is (1, 5), indices imply (5, 5). This error is due to the shape but I don't know how can I fix that. Can someone help how to fix it.
x = [0,1,2,3,4]
y = [10,20,30,40,50]
z = [100,200,300,400,500]
pandas.DataFrame(x, y, z)
Just this:
pandas.DataFrame([x,y,z]).T
Without the .T
, you are making x
, y
, z
each a column. Then you transpose it to get the format you want.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.