Python Pandas - Return a new Timestamp representing UTC day and time



To return a new Timestamp representing UTC day and time, use the timestamp.utcnow() method. At first, import the required libraries −

import pandas as pd

Creating a timestamp

timestamp = pd.Timestamp('2021-10-16T15:12:34.261811624', tz='UTC') 

New timestamp with UTC day and time

timestamp.utcnow()

Example

Following is the code

 import pandas as pd # creating a timestamp timestamp = pd.Timestamp('2021-10-16T15:12:34.261811624', tz='UTC') # display the Timestamp print("Timestamp...\n", timestamp) # new timestamp with UTC day and time print("\nUTC day and time...\n", timestamp.utcnow())

Output

This will produce the following code

 Timestamp... 2021-10-16 15:12:34.261811624+00:00 UTC day and time... 2021-10-03 07:56:08.901294+00:00
Updated on: 2021-10-13T07:21:52+05:30

303 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements