如何将Pandas数据框中的日期列和小时列更改为单个日期时间列

时间:2019-03-20 21:12:03

标签: python pandas datetime dataframe

我在pandas中有一个温度数据框,其创建如下:

+----------+-----+-----+
|  date    | hour| temp|
+----------+-----+-----+
|2000-01-01|  2  | -8  |
+----------+-----+-----+
|2000-01-01|  3  | -10 |
+----------+-----+-----+
|2000-01-02|  4  | -11 |
+----------+-----+-----+
|2000-01-02|  11 | -8  |
+----------+-----+-----+
|2000-01-03|  2  | -7  |
+----------+-----+-----+

我想将其更改为以下数据框:

+-------------------+-----+
|      date         | temp|
+-------------------+-----+
|2000-01-01 02:00:00| -8  |
+-------------------+-----+
|2000-01-01 03:00:00| -10 |
+-------------------+-----+
|2000-01-02 04:00:00| -11 |
+-------------------+-----+
|2000-01-02 11:00:00| -8  |
+-------------------+-----+
|2000-01-03 02:00:00| -7  |
+-------------------+-----+

有什么想法吗?

0 个答案:

没有答案