> ## Content Index
> Fetch the complete content index at: https://datascientyst.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Timezone-aware and naive timestamp in Pandas
- URL: https://datascientyst.com/timezone-and-naive-timestamp-in-pandas/
- Published: 2022-08-24T14:18:47.000Z
- Updated: 2025-03-25T16:37:07.000Z
- Author: John D K
- Tags: Time Series

In Pandas `datetime` can be two types:

- `naive` \- no time zone information  
  - `Timestamp('2022-08-24 16:53:23.186691')`
- `aware` \- time zone information and local time  
  - `Timestamp('2022-08-24 15:53:23.595457+0200', tz='Europe/Rome')`

**Pro Tip 1**  
Always work with timezone information when possible. It's recommended to work with a single time zone - usually it's UTC. 

Below we can find several **Pandas examples of timestamps naive and aware**.

## Naive (local time)

The first example shows how to **get the current date and time as a naive timestamp in Pandas.**

```python
pd.Timestamp.now()

```

result:

```
Timestamp('2022-08-24 16:53:23.186691')

```

## Timezone aware (UTC)

Get **UTC time as timezone aware timestamp in Pandas:**

```python
pd.Timestamp.utcnow()

```

result:

```
Timestamp('2022-08-24 13:53:23.387282+0000', tz='UTC')

```

## Naive (local time)

We can get the local time of any time zone as naive timestamp by:

```python
pd.Timestamp.now(tz='Europe/Rome').tz_localize(None)

```

result:

```
Timestamp('2022-08-24 15:53:23.783935')

```

## Timezone aware (local time)

To use the time aware local time in Pandas:

```python
pd.Timestamp.now(tz='Europe/Rome')

```

result:

```
Timestamp('2022-08-24 15:53:23.595457+0200', tz='Europe/Rome')   

```

## Naive (UTC)

There are multiple ways to get naive UTC time. Below we will describe some of them.

### tz\_localize

The method [pandas.DataFrame.tz\_localize](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.tz%5Flocalize.html?highlight=tz%5Flocalize&ref=datascientyst.com) will localize the tz-naive index of a Series or DataFrame to target the time zone.

```python
pd.Timestamp.utcnow().tz_localize(None)  

```

result:

```
Timestamp('2022-08-24 13:53:24.147123')    

```

### tz\_convert

Method [pandas.DataFrame.tz\_convert](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.tz%5Fconvert.html?ref=datascientyst.com) convert the tz-aware axis to the target time zone.

```python
pd.Timestamp.utcnow().tz_convert(None)

```

result:

```
Timestamp('2022-08-24 13:53:24.377683')

```

**Pro Tip 1**  
Difference between 

tz_convert

 and 

tz_localize

 is that first removes the timezone information resulting in naive local time while second remove the timezone information but converting to UTC, so giving naive UTC time 

### tz\_convert and .now(tz='Europe/Rome')

One more example for `tz_convert(None)`:

```python
pd.Timestamp.now(tz='Europe/Rome').tz_convert(None)

```

result:

```
Timestamp('2022-08-24 13:53:23.983624')

```

![](https://datascientyst.com/content/images/2022/08/timezone-and-naive-timestamp-in-pandas.png)

## Pandas to\_datetime - naive or aware

Pandas `to_datetime` method has parameter: `utc`:

- **True** \- the function always returns a timezone-aware UTC-localized Timestamp, Series or DatetimeIndex.  
  - To do this, timezone-naive inputs are localized as UTC, while timezone-aware inputs are converted to UTC.
- **False** \- inputs will not be coerced to UTC.  
  - Timezone-naive inputs will remain naive, while timezone-aware ones will keep their time offsets. Limitations exist for mixed offsets (typically, daylight savings), see Examples section for details.

More examples and explanation can be found here: [pandas.to\_datetime](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.to%5Fdatetime.html?ref=datascientyst.com)