0

I am trying to strip timezone from the column 'ds'

ds
2023-06-01 00:00:00+00:00
2023-06-01 01:00:00+00:00
2023-06-01 02:00:00+00:00
2023-06-01 03:00:00+00:00
2023-06-01 04:00:00+00:00

Tried the following code :

Usage_df_V2['ds'].astype(str).str[:-6] but it strips off the hours as well:

2023-06-01 00:00:00
2023-06-01 00:00:00
2023-06-01 00:00:00
2023-06-01 00:00:00
2023-06-01 00:00:00

Also tried the tz_convert but it strips of the time

Usage_df_V2['ds'].dt.tz_convert(None) 

& get the following:

2023-06-01
2023-06-01
2023-06-01
2023-06-01
2023-06-01

Can someone help ?

FObersteiner
  • 22,500
  • 8
  • 42
  • 72
Lopa
  • 51
  • 6
  • 1
    do you want to remove the time zone from the *data structure* or do you want to *display* the data in a certain format, i.e. without the UTC offset / time zone information? For example, if a pandas datetime is *displayed* as `2023-06-01`, that does not mean that the hour isn't defined; it is rather just zero. – FObersteiner Jun 29 '23 at 16:58

1 Answers1

1

You almost got it right. You can drop the timezone like so:

Usage_df_V2['ds'].dt.tz_localize(None)
Thaodan
  • 28
  • 1
  • 4