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


Python testing.reset_display_options方法代码示例

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


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

示例1: test_repr_html

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import reset_display_options [as 别名]
def test_repr_html(self):
        self.frame._repr_html_()

        fmt.set_option('display.max_rows', 1, 'display.max_columns', 1)
        self.frame._repr_html_()

        fmt.set_option('display.notebook_repr_html', False)
        self.frame._repr_html_()

        tm.reset_display_options()

        df = DataFrame([[1, 2], [3, 4]])
        fmt.set_option('display.show_dimensions', True)
        assert '2 rows' in df._repr_html_()
        fmt.set_option('display.show_dimensions', False)
        assert '2 rows' not in df._repr_html_()

        tm.reset_display_options() 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:20,代码来源:test_format.py

示例2: test_format_sparse_config

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import reset_display_options [as 别名]
def test_format_sparse_config(idx):
    warn_filters = warnings.filters
    warnings.filterwarnings('ignore', category=FutureWarning,
                            module=".*format")
    # GH1538
    pd.set_option('display.multi_sparse', False)

    result = idx.format()
    assert result[1] == 'foo  two'

    tm.reset_display_options()

    warnings.filters = warn_filters 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:15,代码来源:test_format.py

示例3: test_repr_unsortable

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import reset_display_options [as 别名]
def test_repr_unsortable(self):
        # columns are not sortable
        import warnings
        warn_filters = warnings.filters
        warnings.filterwarnings('ignore',
                                category=FutureWarning,
                                module=".*format")

        unsortable = DataFrame({'foo': [1] * 50,
                                datetime.today(): [1] * 50,
                                'bar': ['bar'] * 50,
                                datetime.today() + timedelta(1): ['bar'] * 50},
                               index=np.arange(50))
        repr(unsortable)

        fmt.set_option('display.precision', 3, 'display.column_space', 10)
        repr(self.frame)

        fmt.set_option('display.max_rows', 10, 'display.max_columns', 2)
        repr(self.frame)

        fmt.set_option('display.max_rows', 1000, 'display.max_columns', 1000)
        repr(self.frame)

        tm.reset_display_options()

        warnings.filters = warn_filters 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:29,代码来源:test_repr_info.py

示例4: test_eng_float_formatter

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import reset_display_options [as 别名]
def test_eng_float_formatter(self):
        self.frame.loc[5] = 0

        fmt.set_eng_float_format()
        repr(self.frame)

        fmt.set_eng_float_format(use_eng_prefix=True)
        repr(self.frame)

        fmt.set_eng_float_format(accuracy=0)
        repr(self.frame)
        tm.reset_display_options() 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:14,代码来源:test_format.py

示例5: test_to_string_left_justify_cols

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import reset_display_options [as 别名]
def test_to_string_left_justify_cols(self):
        tm.reset_display_options()
        df = DataFrame({'x': [3234, 0.253]})
        df_s = df.to_string(justify='left')
        expected = ('   x       \n' '0  3234.000\n' '1     0.253')
        assert df_s == expected 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:8,代码来源:test_format.py

示例6: test_to_string_format_inf

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import reset_display_options [as 别名]
def test_to_string_format_inf(self):
        # Issue #24861
        tm.reset_display_options()
        df = DataFrame({
            'A': [-np.inf, np.inf, -1, -2.1234, 3, 4],
            'B': [-np.inf, np.inf, 'foo', 'foooo', 'fooooo', 'bar']
        })
        result = df.to_string()

        expected = ('        A       B\n'
                    '0    -inf    -inf\n'
                    '1     inf     inf\n'
                    '2 -1.0000     foo\n'
                    '3 -2.1234   foooo\n'
                    '4  3.0000  fooooo\n'
                    '5  4.0000     bar')
        assert result == expected

        df = DataFrame({
            'A': [-np.inf, np.inf, -1., -2., 3., 4.],
            'B': [-np.inf, np.inf, 'foo', 'foooo', 'fooooo', 'bar']
        })
        result = df.to_string()

        expected = ('     A       B\n'
                    '0 -inf    -inf\n'
                    '1  inf     inf\n'
                    '2 -1.0     foo\n'
                    '3 -2.0   foooo\n'
                    '4  3.0  fooooo\n'
                    '5  4.0     bar')
        assert result == expected 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:34,代码来源:test_format.py

示例7: test_fake_qtconsole_repr_html

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import reset_display_options [as 别名]
def test_fake_qtconsole_repr_html(self):
        def get_ipython():
            return {'config': {'KernelApp':
                               {'parent_appname': 'ipython-qtconsole'}}}

        repstr = self.frame._repr_html_()
        assert repstr is not None

        fmt.set_option('display.max_rows', 5, 'display.max_columns', 2)
        repstr = self.frame._repr_html_()

        assert 'class' in repstr  # info fallback
        tm.reset_display_options() 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:15,代码来源:test_format.py

示例8: test_eng_float_formatter

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import reset_display_options [as 别名]
def test_eng_float_formatter(self):
        df = DataFrame({'A': [1.41, 141., 14100, 1410000.]})

        fmt.set_eng_float_format()
        result = df.to_string()
        expected = ('             A\n'
                    '0    1.410E+00\n'
                    '1  141.000E+00\n'
                    '2   14.100E+03\n'
                    '3    1.410E+06')
        assert result == expected

        fmt.set_eng_float_format(use_eng_prefix=True)
        result = df.to_string()
        expected = ('         A\n'
                    '0    1.410\n'
                    '1  141.000\n'
                    '2  14.100k\n'
                    '3   1.410M')
        assert result == expected

        fmt.set_eng_float_format(accuracy=0)
        result = df.to_string()
        expected = ('         A\n'
                    '0    1E+00\n'
                    '1  141E+00\n'
                    '2   14E+03\n'
                    '3    1E+06')
        assert result == expected

        tm.reset_display_options() 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:33,代码来源:test_eng_formatting.py

示例9: test_nan

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import reset_display_options [as 别名]
def test_nan(self):
        # Issue #11981

        formatter = fmt.EngFormatter(accuracy=1, use_eng_prefix=True)
        result = formatter(np.nan)
        assert result == u('NaN')

        df = pd.DataFrame({'a': [1.5, 10.3, 20.5],
                           'b': [50.3, 60.67, 70.12],
                           'c': [100.2, 101.33, 120.33]})
        pt = df.pivot_table(values='a', index='b', columns='c')
        fmt.set_eng_float_format(accuracy=1)
        result = pt.to_string()
        assert 'NaN' in result
        tm.reset_display_options() 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:17,代码来源:test_eng_formatting.py

示例10: test_format_sparse_config

# 需要导入模块: from pandas.util import testing [as 别名]
# 或者: from pandas.util.testing import reset_display_options [as 别名]
def test_format_sparse_config(self):
        warn_filters = warnings.filters
        warnings.filterwarnings('ignore', category=FutureWarning,
                                module=".*format")
        # GH1538
        pd.set_option('display.multi_sparse', False)

        result = self.index.format()
        assert result[1] == 'foo  two'

        tm.reset_display_options()

        warnings.filters = warn_filters 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:15,代码来源:test_multi.py


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