What do you want to save?
Add Code snippet
New code examples
-
Python 2022-01-29 10:51:02
index to datetime pandas
df.index = pd.to_datetime(df.index) Add solution -
Python 2022-01-25 17:51:13
how to add 30 minutes in datetime column in pandas
df['time'] = pd.to_datetime(df['time'].astype(str)) + pd.DateOffset(hours=5, minutes=30) print(df['time'].head()) 0 2018-12-24 10:20:00 1 2018-12-24 10:20:00 2 2018-12-24 10:30:00 3 2018-12-24 10:42:00 4 2018-12-24 11:34:00 Name: 1, dtype: dat... Add solution -
Python 2022-01-24 11:55:49
File "pandas/_libs/index.pyx", line 465, in pandas._libs.index.DatetimeEngine.get_loc KeyError: Timestamp('2019-01-02 07:09:00')
#check if DatetimeIndex print (df_temp.index) #if necessary convert column to index df_temp.set_index('date',inplace=True) #if necessary convert to datetimes df_temp.index= pd.to_datetime(df_temp.index) loc = df_temp.index.get_loc('2015-08-17') Add solution -
Python 2022-01-23 02:25:42
pandas astype datetime
df['col'] = pd.to_datetime(df['col']) Add solution