當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。