Python pandas.get_option() Examples

The following are 30 code examples of pandas.get_option(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pandas , or try the search function .
Example #1
Source File: test_clipboard.py    From Computable with MIT License 6 votes vote down vote up
def setUpClass(cls):
        super(TestClipboard, cls).setUpClass()
        cls.data = {}
        cls.data['string'] = mkdf(5, 3, c_idx_type='s', r_idx_type='i',
                                  c_idx_names=[None], r_idx_names=[None])
        cls.data['int'] = mkdf(5, 3, data_gen_f=lambda *args: randint(2),
                               c_idx_type='s', r_idx_type='i',
                               c_idx_names=[None], r_idx_names=[None])
        cls.data['float'] = mkdf(5, 3,
                                 data_gen_f=lambda r, c: float(r) + 0.01,
                                 c_idx_type='s', r_idx_type='i',
                                 c_idx_names=[None], r_idx_names=[None])
        cls.data['mixed'] = DataFrame({'a': np.arange(1.0, 6.0) + 0.01,
                                       'b': np.arange(1, 6),
                                       'c': list('abcde')})
        # Test GH-5346
        max_rows = get_option('display.max_rows')
        cls.data['longdf'] = mkdf(max_rows+1, 3, data_gen_f=lambda *args: randint(2),
                                  c_idx_type='s', r_idx_type='i',
                                  c_idx_names=[None], r_idx_names=[None])  
        cls.data_types = list(cls.data.keys()) 
Example #2
Source File: test_nbinit.py    From msticpy with MIT License 6 votes vote down vote up
def test_nbinit_no_params():
    """Test init_notebook defaults."""
    ns_dict = {}
    init_notebook(namespace=ns_dict, def_imports="nb")

    check.is_in("pd", ns_dict)
    check.is_in("get_ipython", ns_dict)
    check.is_in("Path", ns_dict)
    check.is_in("np", ns_dict)

    # Note - msticpy imports throw when exec'd from unit test
    # e.g. check.is_in("QueryProvider", ns_dict) fails

    check.is_in("WIDGET_DEFAULTS", ns_dict)

    check.equal(ns_dict["pd"].__name__, "pandas")
    check.equal(ns_dict["np"].__name__, "numpy")

    check.equal(pd.get_option("display.max_columns"), 50) 
Example #3
Source File: parquet.py    From elasticintel with GNU General Public License v3.0 6 votes vote down vote up
def get_engine(engine):
    """ return our implementation """

    if engine == 'auto':
        engine = get_option('io.parquet.engine')

    if engine == 'auto':
        # try engines in this order
        try:
            return PyArrowImpl()
        except ImportError:
            pass

        try:
            return FastParquetImpl()
        except ImportError:
            pass

    if engine not in ['pyarrow', 'fastparquet']:
        raise ValueError("engine must be one of 'pyarrow', 'fastparquet'")

    if engine == 'pyarrow':
        return PyArrowImpl()
    elif engine == 'fastparquet':
        return FastParquetImpl() 
Example #4
Source File: test_repr_pytest.py    From eland with Apache License 2.0 6 votes vote down vote up
def test_empty_dataframe_repr_html(self):
        # TODO - there is a bug in 'show_dimensions' as it gets added after the last </div>
        # For now test without this
        show_dimensions = pd.get_option("display.show_dimensions")
        pd.set_option("display.show_dimensions", False)

        ed_ecom = self.ed_ecommerce()
        pd_ecom = self.pd_ecommerce()

        ed_ecom_rh = ed_ecom[ed_ecom["currency"] == "USD"]._repr_html_()
        pd_ecom_rh = pd_ecom[pd_ecom["currency"] == "USD"]._repr_html_()

        # Restore default
        pd.set_option("display.show_dimensions", show_dimensions)

        assert ed_ecom_rh == pd_ecom_rh 
Example #5
Source File: test_repr_pytest.py    From eland with Apache License 2.0 6 votes vote down vote up
def test_num_rows_repr_html(self):
        # check setup works
        assert pd.get_option("display.max_rows") == 60

        show_dimensions = pd.get_option("display.show_dimensions")

        # TODO - there is a bug in 'show_dimensions' as it gets added after the last </div>
        # For now test without this
        pd.set_option("display.show_dimensions", False)

        # Test eland.DataFrame.to_string vs pandas.DataFrame.to_string
        # In pandas calling 'to_string' without max_rows set, will dump ALL rows

        # Test n-1, n, n+1 for edge cases
        self.num_rows_repr_html(pd.get_option("display.max_rows") - 1)
        self.num_rows_repr_html(pd.get_option("display.max_rows"))
        self.num_rows_repr_html(
            pd.get_option("display.max_rows") + 1, pd.get_option("display.max_rows")
        )

        # Restore default
        pd.set_option("display.show_dimensions", show_dimensions) 
Example #6
Source File: dataframe.py    From modin with Apache License 2.0 6 votes vote down vote up
def _repr_html_(self):  # pragma: no cover
        """repr function for rendering in Jupyter Notebooks like Pandas
        Dataframes.

        Returns:
            The HTML representation of a Dataframe.
        """
        num_rows = pandas.get_option("max_rows") or 60
        num_cols = pandas.get_option("max_columns") or 20

        # We use pandas _repr_html_ to get a string of the HTML representation
        # of the dataframe.
        result = self._build_repr_df(num_rows, num_cols)._repr_html_()
        if len(self.index) > num_rows or len(self.columns) > num_cols:
            # We split so that we insert our correct dataframe dimensions.
            return result.split("<p>")[
                0
            ] + "<p>{0} rows x {1} columns</p>\n</div>".format(
                len(self.index), len(self.columns)
            )
        else:
            return result 
Example #7
Source File: test_repr_pytest.py    From eland with Apache License 2.0 6 votes vote down vote up
def test_num_rows_to_string(self):
        # check setup works
        assert pd.get_option("display.max_rows") == 60

        # Test eland.DataFrame.to_string vs pandas.DataFrame.to_string
        # In pandas calling 'to_string' without max_rows set, will dump ALL rows

        # Test n-1, n, n+1 for edge cases
        self.num_rows_to_string(DEFAULT_NUM_ROWS_DISPLAYED - 1)
        self.num_rows_to_string(DEFAULT_NUM_ROWS_DISPLAYED)
        with pytest.warns(UserWarning):
            # UserWarning displayed by eland here (compare to pandas with max_rows set)
            self.num_rows_to_string(
                DEFAULT_NUM_ROWS_DISPLAYED + 1, None, DEFAULT_NUM_ROWS_DISPLAYED
            )

        # Test for where max_rows lt or gt num_rows
        self.num_rows_to_string(10, 5, 5)
        self.num_rows_to_string(100, 200, 200) 
Example #8
Source File: series.py    From modin with Apache License 2.0 6 votes vote down vote up
def __repr__(self):
        num_rows = pandas.get_option("max_rows") or 60
        num_cols = pandas.get_option("max_columns") or 20
        temp_df = self._build_repr_df(num_rows, num_cols)
        if isinstance(temp_df, pandas.DataFrame):
            temp_df = temp_df.iloc[:, 0]
        temp_str = repr(temp_df)
        if self.name is not None:
            name_str = "Name: {}, ".format(str(self.name))
        else:
            name_str = ""
        if len(self.index) > num_rows:
            len_str = "Length: {}, ".format(len(self.index))
        else:
            len_str = ""
        dtype_str = "dtype: {}".format(temp_str.rsplit("dtype: ", 1)[-1])
        if len(self) == 0:
            return "Series([], {}{}".format(name_str, dtype_str)
        return temp_str.rsplit("\nName:", 1)[0] + "\n{}{}{}".format(
            name_str, len_str, dtype_str
        ) 
Example #9
Source File: plot_utils.py    From jqfactor_analyzer with MIT License 6 votes vote down vote up
def print_table(table, name=None, fmt=None):

    from IPython.display import display

    if isinstance(table, pd.Series):
        table = pd.DataFrame(table)

    if isinstance(table, pd.DataFrame):
        table.columns.name = name

    prev_option = pd.get_option('display.float_format')
    if fmt is not None:
        pd.set_option('display.float_format', lambda x: fmt.format(x))

    display(table)

    if fmt is not None:
        pd.set_option('display.float_format', prev_option) 
Example #10
Source File: core.py    From mars with Apache License 2.0 6 votes vote down vote up
def _repr_html_(self):
        if len(self._executed_sessions) == 0:
            # not executed before, fall back to normal repr
            raise NotImplementedError

        corner_data = fetch_corner_data(
            self, session=self._executed_sessions[-1])

        buf = StringIO()
        max_rows = pd.get_option('display.max_rows')
        if self.shape[0] <= max_rows:
            buf.write(corner_data._repr_html_())
        else:
            with pd.option_context('display.show_dimensions', False,
                                   'display.max_rows', corner_data.shape[0] - 1):
                buf.write(corner_data._repr_html_().rstrip().rstrip('</div>'))
            if pd.get_option('display.show_dimensions'):
                n_rows, n_cols = self.shape
                buf.write(
                    "<p>{nrows} rows × {ncols} columns</p>\n".format(
                        nrows=n_rows, ncols=n_cols)
                )
            buf.write('</div>')

        return buf.getvalue() 
Example #11
Source File: test_utils.py    From mars with Apache License 2.0 6 votes vote down vote up
def testFetchDataFrameCornerData(self):
        max_rows = pd.get_option('display.max_rows')
        try:
            min_rows = pd.get_option('display.min_rows')
        except KeyError:  # pragma: no cover
            min_rows = max_rows
        sess = new_session()

        for row in (5,
                    max_rows - 2,
                    max_rows - 1,
                    max_rows,
                    max_rows + 1,
                    max_rows + 2,
                    max_rows + 3):
            pdf = pd.DataFrame(np.random.rand(row, 5))
            df = DataFrame(pdf, chunk_size=max_rows // 2)
            sess.run(df, fetch=False)

            corner = fetch_corner_data(df, session=sess)
            self.assertLessEqual(corner.shape[0], max_rows + 2)
            corner_max_rows = max_rows if row <= max_rows else corner.shape[0] - 1
            self.assertEqual(corner.to_string(max_rows=corner_max_rows, min_rows=min_rows),
                             pdf.to_string(max_rows=max_rows, min_rows=min_rows),
                             'failed when row == {}'.format(row)) 
Example #12
Source File: test_clipboard.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def setup_class(cls):
        cls.data = {}
        cls.data['string'] = mkdf(5, 3, c_idx_type='s', r_idx_type='i',
                                  c_idx_names=[None], r_idx_names=[None])
        cls.data['int'] = mkdf(5, 3, data_gen_f=lambda *args: randint(2),
                               c_idx_type='s', r_idx_type='i',
                               c_idx_names=[None], r_idx_names=[None])
        cls.data['float'] = mkdf(5, 3,
                                 data_gen_f=lambda r, c: float(r) + 0.01,
                                 c_idx_type='s', r_idx_type='i',
                                 c_idx_names=[None], r_idx_names=[None])
        cls.data['mixed'] = DataFrame({'a': np.arange(1.0, 6.0) + 0.01,
                                       'b': np.arange(1, 6),
                                       'c': list('abcde')})

        # Test columns exceeding "max_colwidth" (GH8305)
        _cw = get_option('display.max_colwidth') + 1
        cls.data['colwidth'] = mkdf(5, 3, data_gen_f=lambda *args: 'x' * _cw,
                                    c_idx_type='s', r_idx_type='i',
                                    c_idx_names=[None], r_idx_names=[None])
        # Test GH-5346
        max_rows = get_option('display.max_rows')
        cls.data['longdf'] = mkdf(max_rows + 1, 3,
                                  data_gen_f=lambda *args: randint(2),
                                  c_idx_type='s', r_idx_type='i',
                                  c_idx_names=[None], r_idx_names=[None])
        # Test for non-ascii text: GH9263
        cls.data['nonascii'] = pd.DataFrame({'en': 'in English'.split(),
                                             'es': 'en español'.split()})
        # unicode round trip test for GH 13747, GH 12529
        cls.data['utf8'] = pd.DataFrame({'a': ['µasd', 'Ωœ∑´'],
                                         'b': ['øπ∆˚¬', 'œ∑´®']})
        cls.data_types = list(cls.data.keys()) 
Example #13
Source File: common.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def _ensure_decoded(s):
    """ if we have bytes, decode them to unicode """
    if isinstance(s, (np.bytes_, bytes)):
        s = s.decode(pd.get_option('display.encoding'))
    return s 
Example #14
Source File: parquet.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def get_engine(engine):
    """ return our implementation """

    if engine == 'auto':
        engine = get_option('io.parquet.engine')

    if engine == 'auto':
        # try engines in this order
        try:
            return PyArrowImpl()
        except ImportError:
            pass

        try:
            return FastParquetImpl()
        except ImportError:
            pass

        raise ImportError("Unable to find a usable engine; "
                          "tried using: 'pyarrow', 'fastparquet'.\n"
                          "pyarrow or fastparquet is required for parquet "
                          "support")

    if engine not in ['pyarrow', 'fastparquet']:
        raise ValueError("engine must be one of 'pyarrow', 'fastparquet'")

    if engine == 'pyarrow':
        return PyArrowImpl()
    elif engine == 'fastparquet':
        return FastParquetImpl() 
Example #15
Source File: test_nanops.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def test_use_bottleneck():

    if nanops._BOTTLENECK_INSTALLED:

        pd.set_option('use_bottleneck', True)
        assert pd.get_option('use_bottleneck')

        pd.set_option('use_bottleneck', False)
        assert not pd.get_option('use_bottleneck')

        pd.set_option('use_bottleneck', use_bn) 
Example #16
Source File: long_path_formatter.py    From astromodels with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def long_path_formatter(line, max_width=pd.get_option('max_colwidth')):
    """
    If a path is longer than max_width, it substitute it with the first and last element,
    joined by "...". For example 'this.is.a.long.path.which.we.want.to.shorten' becomes
    'this...shorten'

    :param line:
    :param max_width:
    :return:
    """

    if len(line) > max_width:

        tokens = line.split(".")
        trial1 = "%s...%s" % (tokens[0], tokens[-1])

        if len(trial1) > max_width:

            return "...%s" %(tokens[-1][-1:-(max_width-3)])

        else:

            return trial1

    else:

        return line 
Example #17
Source File: utils.py    From WindAdapter with MIT License 5 votes vote down vote up
def print_table(table, name=None, fmt=None):
    """
    Pretty print a pandas DataFrame.
    Uses HTML output if running inside Jupyter Notebook, otherwise
    formatted text output.
    Parameters
    ----------
    table : pandas.Series or pandas.DataFrame
        Table to pretty-print.
    name : str, optional
        Table name to display in upper left corner.
    fmt : str, optional
        Formatter to use for displaying table elements.
        E.g. '{0:.2f}%' for displaying 100 as '100.00%'.
        Restores original setting after displaying.
    """

    if isinstance(table, pd.Series):
        table = pd.DataFrame(table)

    if fmt is not None:
        prev_option = pd.get_option('display.float_format')
        pd.set_option('display.float_format', lambda x: fmt.format(x))

    if name is not None:
        table.columns.name = name

    display(table)

    if fmt is not None:
        pd.set_option('display.float_format', prev_option) 
Example #18
Source File: console.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def get_console_size():
    """Return console size as tuple = (width, height).

    Returns (None,None) in non-interactive session.
    """
    from pandas import get_option
    from pandas.core import common as com

    display_width = get_option('display.width')
    # deprecated.
    display_height = get_option('display.max_rows')

    # Consider
    # interactive shell terminal, can detect term size
    # interactive non-shell terminal (ipnb/ipqtconsole), cannot detect term
    # size non-interactive script, should disregard term size

    # in addition
    # width,height have default values, but setting to 'None' signals
    # should use Auto-Detection, But only in interactive shell-terminal.
    # Simple. yeah.

    if com.in_interactive_session():
        if com.in_ipython_frontend():
            # sane defaults for interactive non-shell terminal
            # match default for width,height in config_init
            from pandas.core.config import get_default_val
            terminal_width = get_default_val('display.width')
            terminal_height = get_default_val('display.max_rows')
        else:
            # pure terminal
            terminal_width, terminal_height = get_terminal_size()
    else:
        terminal_width, terminal_height = None, None

    # Note if the User sets width/Height to None (auto-detection)
    # and we're in a script (non-inter), this will return (None,None)
    # caller needs to deal.
    return (display_width or terminal_width, display_height or terminal_height) 
Example #19
Source File: test_clipboard.py    From recruit with Apache License 2.0 5 votes vote down vote up
def df(request):
    data_type = request.param

    if data_type == 'delims':
        return pd.DataFrame({'a': ['"a,\t"b|c', 'd\tef´'],
                             'b': ['hi\'j', 'k\'\'lm']})
    elif data_type == 'utf8':
        return pd.DataFrame({'a': ['µasd', 'Ωœ∑´'],
                             'b': ['øπ∆˚¬', 'œ∑´®']})
    elif data_type == 'string':
        return mkdf(5, 3, c_idx_type='s', r_idx_type='i',
                    c_idx_names=[None], r_idx_names=[None])
    elif data_type == 'long':
        max_rows = get_option('display.max_rows')
        return mkdf(max_rows + 1, 3,
                    data_gen_f=lambda *args: randint(2),
                    c_idx_type='s', r_idx_type='i',
                    c_idx_names=[None], r_idx_names=[None])
    elif data_type == 'nonascii':
        return pd.DataFrame({'en': 'in English'.split(),
                             'es': 'en español'.split()})
    elif data_type == 'colwidth':
        _cw = get_option('display.max_colwidth') + 1
        return mkdf(5, 3, data_gen_f=lambda *args: 'x' * _cw,
                    c_idx_type='s', r_idx_type='i',
                    c_idx_names=[None], r_idx_names=[None])
    elif data_type == 'mixed':
        return DataFrame({'a': np.arange(1.0, 6.0) + 0.01,
                          'b': np.arange(1, 6),
                          'c': list('abcde')})
    elif data_type == 'float':
        return mkdf(5, 3, data_gen_f=lambda r, c: float(r) + 0.01,
                    c_idx_type='s', r_idx_type='i',
                    c_idx_names=[None], r_idx_names=[None])
    elif data_type == 'int':
        return mkdf(5, 3, data_gen_f=lambda *args: randint(2),
                    c_idx_type='s', r_idx_type='i',
                    c_idx_names=[None], r_idx_names=[None])
    else:
        raise ValueError 
Example #20
Source File: console.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def get_console_size():
    """Return console size as tuple = (width, height).

    Returns (None,None) in non-interactive session.
    """
    from pandas import get_option
    from pandas.core import common as com

    display_width = get_option('display.width')
    # deprecated.
    display_height = get_option('display.max_rows')

    # Consider
    # interactive shell terminal, can detect term size
    # interactive non-shell terminal (ipnb/ipqtconsole), cannot detect term
    # size non-interactive script, should disregard term size

    # in addition
    # width,height have default values, but setting to 'None' signals
    # should use Auto-Detection, But only in interactive shell-terminal.
    # Simple. yeah.

    if com.in_interactive_session():
        if com.in_ipython_frontend():
            # sane defaults for interactive non-shell terminal
            # match default for width,height in config_init
            from pandas.core.config import get_default_val
            terminal_width = get_default_val('display.width')
            terminal_height = get_default_val('display.max_rows')
        else:
            # pure terminal
            terminal_width, terminal_height = get_terminal_size()
    else:
        terminal_width, terminal_height = None, None

    # Note if the User sets width/Height to None (auto-detection)
    # and we're in a script (non-inter), this will return (None,None)
    # caller needs to deal.
    return (display_width or terminal_width, display_height or terminal_height) 
Example #21
Source File: dataframe.py    From modin with Apache License 2.0 5 votes vote down vote up
def __repr__(self):
        from pandas.io.formats import console

        num_rows = pandas.get_option("display.max_rows") or 10
        num_cols = pandas.get_option("display.max_columns") or 20
        if pandas.get_option("display.max_columns") is None and pandas.get_option(
            "display.expand_frame_repr"
        ):
            width, _ = console.get_console_size()
            col_counter = 0
            i = 0
            while col_counter < width:
                col_counter += len(str(self.columns[i])) + 1
                i += 1

            num_cols = i
            i = len(self.columns) - 1
            col_counter = 0
            while col_counter < width:
                col_counter += len(str(self.columns[i])) + 1
                i -= 1

            num_cols += len(self.columns) - i
        result = repr(self._build_repr_df(num_rows, num_cols))
        if len(self.index) > num_rows or len(self.columns) > num_cols:
            # The split here is so that we don't repr pandas row lengths.
            return result.rsplit("\n\n", 1)[0] + "\n\n[{0} rows x {1} columns]".format(
                len(self.index), len(self.columns)
            )
        else:
            return result 
Example #22
Source File: dataframe.py    From eland with Apache License 2.0 5 votes vote down vote up
def __repr__(self):
        """
        From pandas
        """
        buf = StringIO()

        # max_rows and max_cols determine the maximum size of the pretty printed tabular
        # representation of the dataframe. pandas defaults are 60 and 20 respectively.
        # dataframes where len(df) > max_rows shows a truncated view with 10 rows shown.
        max_rows = pd.get_option("display.max_rows")
        max_cols = pd.get_option("display.max_columns")
        min_rows = pd.get_option("display.min_rows")

        if len(self) > max_rows:
            max_rows = min_rows

        show_dimensions = pd.get_option("display.show_dimensions")
        if pd.get_option("display.expand_frame_repr"):
            width, _ = console.get_console_size()
        else:
            width = None

        self.to_string(
            buf=buf,
            max_rows=max_rows,
            max_cols=max_cols,
            line_width=width,
            show_dimensions=show_dimensions,
        )

        return buf.getvalue() 
Example #23
Source File: dataframe.py    From eland with Apache License 2.0 5 votes vote down vote up
def _info_repr(self):
        """
        True if the repr should show the info view.
        """
        info_repr_option = pd.get_option("display.large_repr") == "info"
        return info_repr_option and not (
            self._repr_fits_horizontal_() and self._repr_fits_vertical_()
        ) 
Example #24
Source File: dataframe.py    From eland with Apache License 2.0 5 votes vote down vote up
def _repr_html_(self):
        """
        From pandas - this is called by notebooks
        """
        if self._info_repr():
            buf = StringIO("")
            self.info(buf=buf)
            # need to escape the <class>, should be the first line.
            val = buf.getvalue().replace("<", r"&lt;", 1)
            val = val.replace(">", r"&gt;", 1)
            return "<pre>" + val + "</pre>"

        if pd.get_option("display.notebook_repr_html"):
            max_rows = pd.get_option("display.max_rows")
            max_cols = pd.get_option("display.max_columns")
            min_rows = pd.get_option("display.min_rows")
            show_dimensions = pd.get_option("display.show_dimensions")

            if len(self) > max_rows:
                max_rows = min_rows

            return self.to_html(
                max_rows=max_rows,
                max_cols=max_cols,
                show_dimensions=show_dimensions,
                notebook=True,
            )  # set for consistency with pandas output
        else:
            return None 
Example #25
Source File: test_repr_pytest.py    From eland with Apache License 2.0 5 votes vote down vote up
def test_num_rows_repr(self):
        self.num_rows_repr(
            pd.get_option("display.max_rows") - 1, pd.get_option("display.max_rows") - 1
        )
        self.num_rows_repr(
            pd.get_option("display.max_rows"), pd.get_option("display.max_rows")
        )
        self.num_rows_repr(
            pd.get_option("display.max_rows") + 1, pd.get_option("display.min_rows")
        ) 
Example #26
Source File: series.py    From eland with Apache License 2.0 5 votes vote down vote up
def __repr__(self):
        """
        Return a string representation for a particular Series.
        """
        buf = StringIO()

        # max_rows and max_cols determine the maximum size of the pretty printed tabular
        # representation of the series. pandas defaults are 60 and 20 respectively.
        # series where len(series) > max_rows shows a truncated view with 10 rows shown.
        max_rows = pd.get_option("display.max_rows")
        min_rows = pd.get_option("display.min_rows")

        if len(self) > max_rows:
            max_rows = min_rows

        show_dimensions = pd.get_option("display.show_dimensions")

        self.to_string(
            buf=buf,
            name=self.name,
            dtype=True,
            min_rows=min_rows,
            max_rows=max_rows,
            length=show_dimensions,
        )
        result = buf.getvalue()

        return result 
Example #27
Source File: test_nanops.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_use_bottleneck():

    if nanops._BOTTLENECK_INSTALLED:

        pd.set_option('use_bottleneck', True)
        assert pd.get_option('use_bottleneck')

        pd.set_option('use_bottleneck', False)
        assert not pd.get_option('use_bottleneck')

        pd.set_option('use_bottleneck', use_bn) 
Example #28
Source File: conftest.py    From altair_pandas with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def with_plotting_backend(request):
    default = pd.get_option("plotting.backend")
    pd.set_option("plotting.backend", request.config.getoption("backend_name"))
    yield
    try:
        pd.set_option("plotting.backend", default)
    except ImportError:
        pass  # matplotlib is not installed. 
Example #29
Source File: common.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def _ensure_decoded(s):
    """ if we have bytes, decode them to unicode """
    if isinstance(s, (np.bytes_, bytes)):
        s = s.decode(pd.get_option('display.encoding'))
    return s 
Example #30
Source File: test_nanops.py    From recruit with Apache License 2.0 5 votes vote down vote up
def test_use_bottleneck():

    if nanops._BOTTLENECK_INSTALLED:

        pd.set_option('use_bottleneck', True)
        assert pd.get_option('use_bottleneck')

        pd.set_option('use_bottleneck', False)
        assert not pd.get_option('use_bottleneck')

        pd.set_option('use_bottleneck', use_bn)