Python|熊猫时间戳.dst
Python是一种用于进行数据分析的出色语言,主要是因为以数据为中心的Python包的奇妙生态系统。 Pandas就是其中之一,它使导入和分析数据变得更加容易。
Pandas Timestamp.dst()
函数返回一个包含 self.tzinfo.dst(self) 值的 timedelta 对象。它返回给定 Timestamp 对象的时区的夏令时。
Syntax : Timestamp.dst()
Parameters : None
Return : 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()
函数返回了一个 timedelta 对象,其中包含给定 Timestamp 对象的夏令时。示例 #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()
函数返回了一个 timedelta 对象,其中包含给定 Timestamp 对象的夏令时。