Python Pandas Timestamp.dst
Python是一种进行数据分析的伟大语言,主要是因为以数据为中心的Python包的奇妙生态系统。Pandas就是这些包中的一个,它使导入和分析数据变得更加容易。
Pandas Timestamp.dst()函数返回一个包含self.tzinfo.dst(self)值的timedelta对象。它返回给定Timestamp对象的时区的夏令时。
语法 :
Timestamp.dst()
参数:无
返回: dst
例子#1:使用Timestamp.dst()函数为给定的Timestamp对象查找夏令时。
# 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)
输出 :

现在我们将使用Timestamp.dst()函数来查找给定对象的dst。
# return the dst
ts.dst()
输出 :

正如我们在输出中看到的,Timestamp.dst()函数已经返回了一个包含给定Timestamp对象的夏令时的timedelta对象。
例子2:使用Timestamp.dst()函数查找给定Timestamp对象的夏令时。
# 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)
输出 :

现在我们将使用Timestamp.dst()函数来查找给定对象的dst。
# return the dst
ts.dst()
输出 :

正如我们在输出中看到的,Timestamp.dst()函数已经返回了一个包含给定Timestamp对象的夏令时的timedelta对象。
极客教程