Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas Timestamp.dst()
function return a timedelta object which contains self.tzinfo.dst(self) value. It returns the Daylight Saving Time for the timezone of the given Timestamp object.
Syntax : Timestamp.dst()
Parameters : None
Return : dst
Example #1: Use Timestamp.dst()
function to find the Daylight Saving Time for the given Timestamp object.
# importing pandas as pd import pandas as pd
# Create the Timestamp object ts = pd.Timestamp( '2015-03-31 15:47:25.901597' , tz = 'US/Eastern' )
# Print the Timestamp object print (ts)
|
Output :
Now we will use the Timestamp.dst()
function to find the dst of the given object.
# return the dst ts.dst() |
Output :
As we can see in the output, the Timestamp.dst()
function has returned a timedelta object containing the Daylight Saving Time for the given Timestamp object.
Example #2: Use Timestamp.dst()
function to find the Daylight Saving Time for the given Timestamp object.
# importing pandas as pd import pandas as pd
# Create the Timestamp object ts = pd.Timestamp(year = 2009 , month = 5 , day = 31 ,
hour = 4 , second = 49 , tz = 'Europe/Berlin' )
# Print the Timestamp object print (ts)
|
Output :
Now we will use the Timestamp.dst()
function to find the dst of the given object.
# return the dst ts.dst() |
Output :
As we can see in the output, the Timestamp.dst()
function has returned a timedelta object containing the Daylight Saving Time for the given Timestamp object.