本文整理汇总了Python中pandas._libs.tslib._test_parse_iso8601方法的典型用法代码示例。如果您正苦于以下问题:Python tslib._test_parse_iso8601方法的具体用法?Python tslib._test_parse_iso8601怎么用?Python tslib._test_parse_iso8601使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas._libs.tslib
的用法示例。
在下文中一共展示了tslib._test_parse_iso8601方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parsers_iso8601
# 需要导入模块: from pandas._libs import tslib [as 别名]
# 或者: from pandas._libs.tslib import _test_parse_iso8601 [as 别名]
def test_parsers_iso8601(date_str, exp):
# see gh-12060
#
# Test only the ISO parser - flexibility to
# different separators and leading zero's.
actual = tslib._test_parse_iso8601(date_str)
assert actual == exp
示例2: test_parsers_iso8601_invalid
# 需要导入模块: from pandas._libs import tslib [as 别名]
# 或者: from pandas._libs.tslib import _test_parse_iso8601 [as 别名]
def test_parsers_iso8601_invalid(date_str):
msg = "Error parsing datetime string \"{s}\"".format(s=date_str)
with pytest.raises(ValueError, match=msg):
tslib._test_parse_iso8601(date_str)
示例3: test_parsers_iso8601_invalid_offset_invalid
# 需要导入模块: from pandas._libs import tslib [as 别名]
# 或者: from pandas._libs.tslib import _test_parse_iso8601 [as 别名]
def test_parsers_iso8601_invalid_offset_invalid():
date_str = "2001-01-01 12-34-56"
msg = ("Timezone hours offset out of range "
"in datetime string \"{s}\"".format(s=date_str))
with pytest.raises(ValueError, match=msg):
tslib._test_parse_iso8601(date_str)
示例4: test_parsers_iso8601
# 需要导入模块: from pandas._libs import tslib [as 别名]
# 或者: from pandas._libs.tslib import _test_parse_iso8601 [as 别名]
def test_parsers_iso8601(self, date_str, exp):
# GH#12060
# test only the iso parser - flexibility to different
# separators and leadings 0s
# Timestamp construction falls back to dateutil
actual = tslib._test_parse_iso8601(date_str)
assert actual == exp
示例5: test_parsers_iso8601_invalid
# 需要导入模块: from pandas._libs import tslib [as 别名]
# 或者: from pandas._libs.tslib import _test_parse_iso8601 [as 别名]
def test_parsers_iso8601_invalid(self, date_str):
# separators must all match - YYYYMM not valid
with pytest.raises(ValueError):
tslib._test_parse_iso8601(date_str)
示例6: test_parsers_iso8601
# 需要导入模块: from pandas._libs import tslib [as 别名]
# 或者: from pandas._libs.tslib import _test_parse_iso8601 [as 别名]
def test_parsers_iso8601(self):
# GH 12060
# test only the iso parser - flexibility to different
# separators and leadings 0s
# Timestamp construction falls back to dateutil
cases = {'2011-01-02': datetime(2011, 1, 2),
'2011-1-2': datetime(2011, 1, 2),
'2011-01': datetime(2011, 1, 1),
'2011-1': datetime(2011, 1, 1),
'2011 01 02': datetime(2011, 1, 2),
'2011.01.02': datetime(2011, 1, 2),
'2011/01/02': datetime(2011, 1, 2),
'2011\\01\\02': datetime(2011, 1, 2),
'2013-01-01 05:30:00': datetime(2013, 1, 1, 5, 30),
'2013-1-1 5:30:00': datetime(2013, 1, 1, 5, 30)}
for date_str, exp in compat.iteritems(cases):
actual = tslib._test_parse_iso8601(date_str)
assert actual == exp
# seperators must all match - YYYYMM not valid
invalid_cases = ['2011-01/02', '2011^11^11',
'201401', '201111', '200101',
# mixed separated and unseparated
'2005-0101', '200501-01',
'20010101 12:3456', '20010101 1234:56',
# HHMMSS must have two digits in each component
# if unseparated
'20010101 1', '20010101 123', '20010101 12345',
'20010101 12345Z',
# wrong separator for HHMMSS
'2001-01-01 12-34-56']
for date_str in invalid_cases:
with pytest.raises(ValueError):
tslib._test_parse_iso8601(date_str)
# If no ValueError raised, let me know which case failed.
raise Exception(date_str)