Пример #1
0
 def test_frame_info_encoding(self):
     index = ["'Til There Was You (1997)", "ldum klaka (Cold Fever) (1994)"]
     fmt.set_printoptions(max_rows=1)
     df = DataFrame(columns=["a", "b", "c"], index=index)
     repr(df)
     repr(df.T)
     fmt.set_printoptions(max_rows=200)
Пример #2
0
 def test_frame_info_encoding(self):
     index = ['\'Til There Was You (1997)',
              'ldum klaka (Cold Fever) (1994)']
     fmt.set_printoptions(max_rows=1)
     df = DataFrame(columns=['a', 'b', 'c'], index=index)
     repr(df)
     repr(df.T)
     fmt.set_printoptions(max_rows=200)
Пример #3
0
 def test_frame_info_encoding(self):
     index = ['\'Til There Was You (1997)',
              'ldum klaka (Cold Fever) (1994)']
     fmt.set_printoptions(max_rows=1)
     df = DataFrame(columns=['a', 'b', 'c'], index=index)
     repr(df)
     repr(df.T)
     fmt.set_printoptions(max_rows=200)
Пример #4
0
    def test_repr_html(self):
        self.frame._repr_html_()

        fmt.set_printoptions(max_rows=1, max_columns=1)
        self.frame._repr_html_()

        fmt.set_printoptions(notebook_repr_html=False)
        self.frame._repr_html_()

        fmt.reset_printoptions()
Пример #5
0
    def test_repr_html(self):
        self.frame._repr_html_()

        fmt.set_printoptions(max_rows=1, max_columns=1)
        self.frame._repr_html_()

        fmt.set_printoptions(notebook_repr_html=False)
        self.frame._repr_html_()

        fmt.reset_printoptions()
Пример #6
0
    def test_fake_qtconsole_repr_html(self):
        def get_ipython():
            return {"config": {"KernelApp": {"parent_appname": "ipython-qtconsole"}}}

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

        fmt.set_printoptions(max_rows=5, max_columns=2)

        self.assert_(self.frame._repr_html_() is None)

        fmt.reset_printoptions()
Пример #7
0
    def test_to_string_float_formatting(self):
        fmt.reset_printoptions()
        fmt.set_printoptions(precision=6,
                             column_space=12,
                             notebook_repr_html=False)

        df = DataFrame({
            'x': [
                0, 0.25, 3456.000, 12e+45, 1.64e+6, 1.7e+8, 1.253456, np.pi,
                -1e6
            ]
        })

        df_s = df.to_string()

        # Python 2.5 just wants me to be sad. And debian 32-bit
        #sys.version_info[0] == 2 and sys.version_info[1] < 6:
        if _three_digit_exp():
            expected = ('              x\n0  0.00000e+000\n1  2.50000e-001\n'
                        '2  3.45600e+003\n3  1.20000e+046\n4  1.64000e+006\n'
                        '5  1.70000e+008\n6  1.25346e+000\n7  3.14159e+000\n'
                        '8 -1.00000e+006')
        else:
            expected = ('             x\n0  0.00000e+00\n1  2.50000e-01\n'
                        '2  3.45600e+03\n3  1.20000e+46\n4  1.64000e+06\n'
                        '5  1.70000e+08\n6  1.25346e+00\n7  3.14159e+00\n'
                        '8 -1.00000e+06')
        assert (df_s == expected)

        df = DataFrame({'x': [3234, 0.253]})
        df_s = df.to_string()

        expected = ('          x\n' '0  3234.000\n' '1     0.253')
        assert (df_s == expected)

        fmt.reset_printoptions()
        self.assertEqual(fmt.print_config.precision, 7)

        df = DataFrame({'x': [1e9, 0.2512]})
        df_s = df.to_string()
        # Python 2.5 just wants me to be sad. And debian 32-bit
        #sys.version_info[0] == 2 and sys.version_info[1] < 6:
        if _three_digit_exp():
            expected = ('               x\n'
                        '0  1.000000e+009\n'
                        '1  2.512000e-001')
        else:
            expected = ('              x\n'
                        '0  1.000000e+09\n'
                        '1  2.512000e-01')
        assert (df_s == expected)
Пример #8
0
    def test_to_string_float_formatting(self):
        fmt.reset_printoptions()
        fmt.set_printoptions(precision=6, column_space=12,
                             notebook_repr_html=False)

        df = DataFrame({'x' : [0, 0.25, 3456.000, 12e+45, 1.64e+6,
                               1.7e+8, 1.253456, np.pi, -1e6]})

        df_s = df.to_string()

        # Python 2.5 just wants me to be sad. And debian 32-bit
        #sys.version_info[0] == 2 and sys.version_info[1] < 6:
        if _three_digit_exp():
            expected = ('              x\n0  0.00000e+000\n1  2.50000e-001\n'
                        '2  3.45600e+003\n3  1.20000e+046\n4  1.64000e+006\n'
                        '5  1.70000e+008\n6  1.25346e+000\n7  3.14159e+000\n'
                        '8 -1.00000e+006')
        else:
            expected = ('             x\n0  0.00000e+00\n1  2.50000e-01\n'
                        '2  3.45600e+03\n3  1.20000e+46\n4  1.64000e+06\n'
                        '5  1.70000e+08\n6  1.25346e+00\n7  3.14159e+00\n'
                        '8 -1.00000e+06')
        assert(df_s == expected)

        df = DataFrame({'x' : [3234, 0.253]})
        df_s = df.to_string()

        expected = ('          x\n'
                    '0  3234.000\n'
                    '1     0.253')
        assert(df_s == expected)

        fmt.reset_printoptions()
        self.assertEqual(get_option("display.precision"), 7)

        df = DataFrame({'x': [1e9, 0.2512]})
        df_s = df.to_string()
        # Python 2.5 just wants me to be sad. And debian 32-bit
        #sys.version_info[0] == 2 and sys.version_info[1] < 6:
        if _three_digit_exp():
            expected = ('               x\n'
                        '0  1.000000e+009\n'
                        '1  2.512000e-001')
        else:
            expected = ('              x\n'
                        '0  1.000000e+09\n'
                        '1  2.512000e-01')
        assert(df_s == expected)
Пример #9
0
    def test_fake_qtconsole_repr_html(self):
        def get_ipython():
            return {
                'config': {
                    'KernelApp': {
                        'parent_appname': 'ipython-qtconsole'
                    }
                }
            }

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

        fmt.set_printoptions(max_rows=5, max_columns=2)

        self.assert_(self.frame._repr_html_() is None)

        fmt.reset_printoptions()
Пример #10
0
    def test_to_string_float_formatting(self):
        fmt.reset_printoptions()
        fmt.set_printoptions(precision=6, column_space=12, notebook_repr_html=False)

        df = DataFrame({"x": [0, 0.25, 3456.000, 12e45, 1.64e6, 1.7e8, 1.253456, np.pi, -1e6]})

        df_s = df.to_string()

        # Python 2.5 just wants me to be sad. And debian 32-bit
        # sys.version_info[0] == 2 and sys.version_info[1] < 6:
        if _three_digit_exp():
            expected = (
                "              x\n0  0.00000e+000\n1  2.50000e-001\n"
                "2  3.45600e+003\n3  1.20000e+046\n4  1.64000e+006\n"
                "5  1.70000e+008\n6  1.25346e+000\n7  3.14159e+000\n"
                "8 -1.00000e+006"
            )
        else:
            expected = (
                "             x\n0  0.00000e+00\n1  2.50000e-01\n"
                "2  3.45600e+03\n3  1.20000e+46\n4  1.64000e+06\n"
                "5  1.70000e+08\n6  1.25346e+00\n7  3.14159e+00\n"
                "8 -1.00000e+06"
            )
        assert df_s == expected

        df = DataFrame({"x": [3234, 0.253]})
        df_s = df.to_string()

        expected = "          x\n" "0  3234.000\n" "1     0.253"
        assert df_s == expected

        fmt.reset_printoptions()
        self.assertEqual(fmt.print_config.precision, 7)

        df = DataFrame({"x": [1e9, 0.2512]})
        df_s = df.to_string()
        # Python 2.5 just wants me to be sad. And debian 32-bit
        # sys.version_info[0] == 2 and sys.version_info[1] < 6:
        if _three_digit_exp():
            expected = "               x\n" "0  1.000000e+009\n" "1  2.512000e-001"
        else:
            expected = "              x\n" "0  1.000000e+09\n" "1  2.512000e-01"
        assert df_s == expected