[英]How to introduce new index values in a data frame?
I have the following dataframe, which the print(df_74034.head(10))
is: 我有以下数据
print(df_74034.head(10))
, print(df_74034.head(10))
是:
HumExamRoom HumTechRoom Machine TempExamRoom TempTechRoom
NaN 2017-08-18\t09:22:33\t65.9 74034 NaN NaN
NaN 2017-10-03\t11:08:26\t60.5 74034 NaN NaN
2018-02-17\t01:45:24 NaN 69.7 74034 NaN NaN
2018-02-17\t01:45:55 NaN 67.5 74034 NaN NaN
2018-02-17\t01:46:29 NaN 65.4 74034 NaN NaN
2018-02-17\t01:47:20 NaN 63.3 74034 NaN NaN
2018-02-17\t01:48:35 NaN 61.3 74034 NaN NaN
2018-02-17\t01:49:08 NaN 63.4 74034 NaN NaN
2018-02-17\t01:49:31 NaN 65.5 74034 NaN NaN
2018-02-17\t01:49:55 NaN 67.6 74034 NaN NaN
(The first two rows got a little messy) As you can see, the first two cells in the index have no values at all because their values are in the second column, which is probably a fault of my code - which I don't want to change anymore. (前两行有点杂乱)正如你所看到的,索引中的前两个单元格根本没有值,因为它们的值在第二列中,这可能是我的代码的错误 - 我不知道想要改变了。 Therefore, I would like to introduce the values
2017-08-18\\t09:22:33\\t
and `2017-08-18\\t09:22:33\\t' in the index cells, respectively, and sort it. 因此,我想分别在索引单元格中引入值
2017-08-18\\t09:22:33\\t
和“2017-08-18 \\ t09:22:33 \\ t”,并对其进行排序。 In order to sort I also have to change it to its correct date/time format. 为了排序我还必须将其更改为正确的日期/时间格式。
I've already tried df_74034.index.insert(0, '2017-08-18\\t09:22:33')
but it didn't work. 我已经尝试过
df_74034.index.insert(0, '2017-08-18\\t09:22:33')
但它没有用。 I appretiate for the help! 我乐意为你提供帮助!
You can perform it in other way - 你可以用其他方式执行它 -
df = dataframe name which in your case is df_74034. df =数据帧名称,在您的情况下为df_74034。
I hope it may be helpful to some extend. 我希望它可能会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.