Python | Pandas Timestamp.timetz

Python | Pandas Timestamp.timetz

The timetz method of a pandas Timestamp object is used to return a time object with the same time but with tzinfo=None.

Here's a basic demonstration:

import pandas as pd # Create a Timestamp object ts = pd.Timestamp('2023-09-22 12:34:56', tz='US/Eastern') # Print the Timestamp and its time zone info print(ts) # 2023-09-22 12:34:56-04:00 print(ts.tzinfo) # US/Eastern # Use the timetz method time_with_tz = ts.time() print(time_with_tz) # 12:34:56.000000-04:00 # Get the time object with tzinfo set to None time_without_tz = ts.timetz() print(time_without_tz) # 12:34:56 

As you can see, timetz gives you the time portion of the Timestamp without any time zone information, while using the time method retains the time zone offset.


More Tags

jks sap-ase linked-list delete-directory gradle-tooling-api continuum iis-10 django dummy-variable bezier

More Programming Guides

Other Guides

More Programming Examples