datetime - Python Pandas Combined Date and Hour Into One Column -


how combine day (datetime64[ns]) , hour (int64) 1 datetime column?

         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 

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] 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -