当前位置: 首页>>代码示例>>Python>>正文


Python parsers.ParserWarning方法代码示例

本文整理汇总了Python中pandas.io.parsers.ParserWarning方法的典型用法代码示例。如果您正苦于以下问题:Python parsers.ParserWarning方法的具体用法?Python parsers.ParserWarning怎么用?Python parsers.ParserWarning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pandas.io.parsers的用法示例。


在下文中一共展示了parsers.ParserWarning方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_c_engine

# 需要导入模块: from pandas.io import parsers [as 别名]
# 或者: from pandas.io.parsers import ParserWarning [as 别名]
def test_c_engine(self):
        # see gh-6607
        data = 'a b c\n1 2 3'
        msg = 'does not support'

        # specify C engine with unsupported options (raise)
        with pytest.raises(ValueError, match=msg):
            read_csv(StringIO(data), engine='c',
                     sep=None, delim_whitespace=False)
        with pytest.raises(ValueError, match=msg):
            read_csv(StringIO(data), engine='c', sep=r'\s')
        with pytest.raises(ValueError, match=msg):
            read_csv(StringIO(data), engine='c', sep='\t', quotechar=chr(128))
        with pytest.raises(ValueError, match=msg):
            read_csv(StringIO(data), engine='c', skipfooter=1)

        # specify C-unsupported options without python-unsupported options
        with tm.assert_produces_warning(parsers.ParserWarning):
            read_csv(StringIO(data), sep=None, delim_whitespace=False)
        with tm.assert_produces_warning(parsers.ParserWarning):
            read_csv(StringIO(data), sep=r'\s')
        with tm.assert_produces_warning(parsers.ParserWarning):
            read_csv(StringIO(data), sep='\t', quotechar=chr(128))
        with tm.assert_produces_warning(parsers.ParserWarning):
            read_csv(StringIO(data), skipfooter=1)

        text = """                      A       B       C       D        E
one two three   four
a   b   10.0032 5    -0.5109 -2.3358 -0.4645  0.05076  0.3640
a   q   20      4     0.4473  1.4152  0.2834  1.00661  0.1744
x   q   30      3    -0.6662 -0.5243 -0.3580  0.89145  2.5838"""
        msg = 'Error tokenizing data'

        with pytest.raises(ParserError, match=msg):
            read_csv(StringIO(text), sep='\\s+')
        with pytest.raises(ParserError, match=msg):
            read_csv(StringIO(text), engine='c', sep='\\s+')

        msg = "Only length-1 thousands markers supported"
        data = """A|B|C
1|2,334|5
10|13|10.
"""
        with pytest.raises(ValueError, match=msg):
            read_csv(StringIO(data), thousands=',,')
        with pytest.raises(ValueError, match=msg):
            read_csv(StringIO(data), thousands='')

        msg = "Only length-1 line terminators supported"
        data = 'a,b,c~~1,2,3~~4,5,6'
        with pytest.raises(ValueError, match=msg):
            read_csv(StringIO(data), lineterminator='~~') 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:54,代码来源:test_unsupported.py

示例2: test_c_engine

# 需要导入模块: from pandas.io import parsers [as 别名]
# 或者: from pandas.io.parsers import ParserWarning [as 别名]
def test_c_engine(self):
        # see gh-6607
        data = 'a b c\n1 2 3'
        msg = 'does not support'

        # specify C engine with unsupported options (raise)
        with tm.assert_raises_regex(ValueError, msg):
            read_table(StringIO(data), engine='c',
                       sep=None, delim_whitespace=False)
        with tm.assert_raises_regex(ValueError, msg):
            read_table(StringIO(data), engine='c', sep=r'\s')
        with tm.assert_raises_regex(ValueError, msg):
            read_table(StringIO(data), engine='c', quotechar=chr(128))
        with tm.assert_raises_regex(ValueError, msg):
            read_table(StringIO(data), engine='c', skipfooter=1)

        # specify C-unsupported options without python-unsupported options
        with tm.assert_produces_warning(parsers.ParserWarning):
            read_table(StringIO(data), sep=None, delim_whitespace=False)
        with tm.assert_produces_warning(parsers.ParserWarning):
            read_table(StringIO(data), quotechar=chr(128))
        with tm.assert_produces_warning(parsers.ParserWarning):
            read_table(StringIO(data), sep=r'\s')
        with tm.assert_produces_warning(parsers.ParserWarning):
            read_table(StringIO(data), skipfooter=1)

        text = """                      A       B       C       D        E
one two three   four
a   b   10.0032 5    -0.5109 -2.3358 -0.4645  0.05076  0.3640
a   q   20      4     0.4473  1.4152  0.2834  1.00661  0.1744
x   q   30      3    -0.6662 -0.5243 -0.3580  0.89145  2.5838"""
        msg = 'Error tokenizing data'

        with tm.assert_raises_regex(ParserError, msg):
            read_table(StringIO(text), sep='\\s+')
        with tm.assert_raises_regex(ParserError, msg):
            read_table(StringIO(text), engine='c', sep='\\s+')

        msg = "Only length-1 thousands markers supported"
        data = """A|B|C
1|2,334|5
10|13|10.
"""
        with tm.assert_raises_regex(ValueError, msg):
            read_csv(StringIO(data), thousands=',,')
        with tm.assert_raises_regex(ValueError, msg):
            read_csv(StringIO(data), thousands='')

        msg = "Only length-1 line terminators supported"
        data = 'a,b,c~~1,2,3~~4,5,6'
        with tm.assert_raises_regex(ValueError, msg):
            read_csv(StringIO(data), lineterminator='~~') 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:54,代码来源:test_unsupported.py


注:本文中的pandas.io.parsers.ParserWarning方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。