2

I have the time in the following format in my dataframe:

print(df)
            Date
    2020-09-25T00:20:00.000Z

Two questions: a) What format is this? b) how can I create a new column with the date and time in Australian time (AEDT).

Any help would be great! Thanks

SOK
  • 1,732
  • 2
  • 15
  • 33

1 Answers1

6

What format is this?

Check link:

The T doesn't really stand for anything. It is just the separator that the ISO 8601 combined date-time format requires. You can read it as an abbreviation for Time.
The Z stands for the Zero timezone, as it is offset by 0 from the Coordinated Universal Time (UTC).

How can I create a new column with the date and time in Australian time (AEDT)?

Convert column to datetimes and then use Series.dt.tz_convert:

df['Date'] = pd.to_datetime(df['Date']).dt.tz_convert('Australia/Sydney')
print (df)
                       Date
0 2020-09-25 10:20:00+10:00
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252
  • Ah great.Thanks @jezrael makes sense! Is there a way of removing the `+10:00` from the output or should i just remove the last 6 characters? – SOK Sep 23 '20 at 08:05
  • @SOK - If need remove timezone information use `df['Date'] = pd.to_datetime(df['Date']).dt.tz_convert(None)` – jezrael Sep 23 '20 at 08:06
  • 2
    Sorry - I would like it to be in the `Australia/Sydney` Timezone still but just would like it to show `2020-09-25 10:20:00` instead of `2020-09-25 10:20:00+10:00` if thats posible? – SOK Sep 23 '20 at 08:09
  • 1
    @SOK - df['Date'] = pd.to_datetime(df['Date']).dt.tz_convert('Australia/Sydney').dt.strftime('%Y-%m-%d %H:%M:%S') – Lukas Sep 23 '20 at 08:17
  • @SOK - If need timezones info then not – jezrael Sep 23 '20 at 08:18