本文整理汇总了Python中pandas.core.api.Timestamp.tz_convert方法的典型用法代码示例。如果您正苦于以下问题:Python Timestamp.tz_convert方法的具体用法?Python Timestamp.tz_convert怎么用?Python Timestamp.tz_convert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas.core.api.Timestamp
的用法示例。
在下文中一共展示了Timestamp.tz_convert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_tz_convert_roundtrip
# 需要导入模块: from pandas.core.api import Timestamp [as 别名]
# 或者: from pandas.core.api.Timestamp import tz_convert [as 别名]
def test_tz_convert_roundtrip(self):
for tz in ["UTC", "Asia/Tokyo", "US/Eastern", "dateutil/US/Pacific"]:
for t in ["2014-02-01 09:00", "2014-07-08 09:00", "2014-11-01 17:00", "2014-11-05 00:00"]:
ts = Timestamp(t, tz="UTC")
converted = ts.tz_convert(tz)
reset = converted.tz_convert(None)
self.assertEqual(reset, Timestamp(t))
self.assertTrue(reset.tzinfo is None)
self.assertEqual(reset, converted.tz_convert("UTC").tz_localize(None))
示例2: test_tz_convert_roundtrip
# 需要导入模块: from pandas.core.api import Timestamp [as 别名]
# 或者: from pandas.core.api.Timestamp import tz_convert [as 别名]
def test_tz_convert_roundtrip(self):
for tz in ['UTC', 'Asia/Tokyo', 'US/Eastern', 'dateutil/US/Pacific']:
for t in ['2014-02-01 09:00', '2014-07-08 09:00', '2014-11-01 17:00',
'2014-11-05 00:00']:
ts = Timestamp(t, tz='UTC')
converted = ts.tz_convert(tz)
reset = converted.tz_convert(None)
self.assertEqual(reset, Timestamp(t))
self.assertTrue(reset.tzinfo is None)
self.assertEqual(reset, converted.tz_convert('UTC').tz_localize(None))