Good morning,
I have a some error and time data in two columns:
edf = pd.DataFrame({'error':error, 'time':time})
Which gives:
error time
0 0.000000e+00 -10.000
1 4.219215e-28 -9.995
2 8.870728e-28 -9.990
3 1.398745e-27 -9.985
4 1.960445e-27 -9.980
5 2.575915e-27 -9.975
6 3.249142e-27 -9.970
7 3.984379e-27 -9.965
8 4.786157e-27 -9.960
9 5.659303e-27 -9.955
10 6.608959e-27 -9.950
According to documentation, I can use edf.set_index('time', drop=True)
in order to set the time column as my index, and drop it from the its previous place in the data frame (I believe it drops by default). However, this does absolutely nothing. In fact, I was so confused, that I decided to copy and paste the code example straight from documentation, and indeed it does not work either.
df = pd.DataFrame({'month': [1, 4, 7, 10],
'year': [2012, 2014, 2013, 2014],
'sale': [55, 40, 84, 31]})
Which gives,
month year sale
0 1 2012 55
1 4 2014 40
2 7 2013 84
3 10 2014 31
After which, df.set_index('month')
also gives:
month year sale
0 1 2012 55
1 4 2014 40
2 7 2013 84
3 10 2014 31
Instead of what documentation advertises:
year sale
month
1 2012 55
4 2014 40
7 2013 84
10 2014 31
What gives?