I've a table which has two columns, the first one is the indice of the site, and the second is the number of states per hour during 24 hours. Thus for each site, I've 24(lines)x2(columns) data. How can I transpose the second column (24 lines data per site) into the line which contains 24+1 columns with site indice.
I've found a naive solution by using loop to create new line:
for i in range(numberOfsites):
i1 = i*24
i2 = i1 + 24
newLine = DataFrame(sitesData,index=list(range(i1,i2)), columns=["siteState"]).T
could anyone propose another easier solution? Thank you in advance.
Original data: (thanks to Andy Hayden for the data)
site_index state
0 1 a
1 1 b
2 1 a
3 2 a
4 2 a
5 2 b
Desired data:
0 1 2
site_index
1 a b a
2 a a b