my ots column has : 2021-04-03 14:01:22.791856
its dtype is dtype('<M8[ns]')
how do I get only 2021-04-03 14:01:22
?
CodePudding user response:
use this: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.dt.strftime.html
considering that is your time column in the pandas dataframe:
df['time'] = df['time'].dt.strftime('%Y-%m-%d %H:%M:%S')