...

/

Compare naive and tz-aware Values

Compare naive and tz-aware Values

Let's look at the types of timestamps and how we can use them.

We'll cover the following...

Try it yourself

Try executing the code below to see the result.

Press + to interact
import pandas as pd
s1 = pd.to_datetime([
'2020-01-01T00:00:00+00:00',
'2020-02-02T00:00:00+00:00',
'2020-03-03T00:00:00+00:00',
])
s2 = pd.Series([
pd.Timestamp(2020, 1, 1),
pd.Timestamp(2020, 2, 2),
pd.Timestamp(2020, 3, 3),
])
print(s1 == s2)
pd.to_datetime(df['timestamp'], unit='s')

Explanation

In pandas and Python, there is one Timestamp or datetime type. However, that one type is divided into these two subtypes:

  1. naive
  2. tz-aware
...