Python Pandas将日期和小时合并为一列

Jar*_*rad 2 python datetime pandas

我如何将Day(datetime64 [ns])和Hour(int64)组合成一个日期时间列?

         Day  Hour
0 2010-04-24    17
1 2012-08-20    10
2 2016-03-06     9
3 2016-01-02    10
4 2010-12-21     4
Run Code Online (Sandbox Code Playgroud)

Ale*_*der 7

df = pd.DataFrame({
    'Day': np.array(['2010-04-24', '2012-08-20', '2016-03-06', '2016-01-02', '2010-12-21'], dtype=np.datetime64), 
    'Hour': np.array([17, 10, 9, 10, 4], dtype=np.int64)})

>>> pd.to_datetime(df.Day) + pd.to_timedelta(df.Hour, unit='h')
0   2010-04-24 17:00:00
1   2012-08-20 10:00:00
2   2016-03-06 09:00:00
3   2016-01-02 10:00:00
4   2010-12-21 04:00:00
dtype: datetime64[ns]
Run Code Online (Sandbox Code Playgroud)