當前位置: 首頁>>代碼示例>>Python>>正文


Python pandas.get_option方法代碼示例

本文整理匯總了Python中pandas.get_option方法的典型用法代碼示例。如果您正苦於以下問題:Python pandas.get_option方法的具體用法?Python pandas.get_option怎麽用?Python pandas.get_option使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pandas的用法示例。


在下文中一共展示了pandas.get_option方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _repr_html_

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import get_option [as 別名]
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() 
開發者ID:mars-project,項目名稱:mars,代碼行數:27,代碼來源:core.py

示例2: testFetchDataFrameCornerData

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import get_option [as 別名]
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)) 
開發者ID:mars-project,項目名稱:mars,代碼行數:27,代碼來源:test_utils.py

示例3: test_nbinit_no_params

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import get_option [as 別名]
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) 
開發者ID:microsoft,項目名稱:msticpy,代碼行數:21,代碼來源:test_nbinit.py

示例4: setUpClass

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import get_option [as 別名]
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()) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:23,代碼來源:test_clipboard.py

示例5: get_engine

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import get_option [as 別名]
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() 
開發者ID:securityclippy,項目名稱:elasticintel,代碼行數:27,代碼來源:parquet.py

示例6: _repr_html_

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import get_option [as 別名]
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 
開發者ID:modin-project,項目名稱:modin,代碼行數:24,代碼來源:dataframe.py

示例7: __repr__

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import get_option [as 別名]
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
        ) 
開發者ID:modin-project,項目名稱:modin,代碼行數:23,代碼來源:series.py

示例8: print_table

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import get_option [as 別名]
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) 
開發者ID:JoinQuant,項目名稱:jqfactor_analyzer,代碼行數:20,代碼來源:plot_utils.py

示例9: test_num_rows_to_string

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import get_option [as 別名]
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) 
開發者ID:elastic,項目名稱:eland,代碼行數:21,代碼來源:test_repr_pytest.py

示例10: test_num_rows_repr_html

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import get_option [as 別名]
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) 
開發者ID:elastic,項目名稱:eland,代碼行數:24,代碼來源:test_repr_pytest.py

示例11: test_empty_dataframe_repr_html

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import get_option [as 別名]
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 
開發者ID:elastic,項目名稱:eland,代碼行數:18,代碼來源:test_repr_pytest.py

示例12: test_use_bottleneck

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import get_option [as 別名]
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) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:13,代碼來源:test_nanops.py

示例13: df

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import get_option [as 別名]
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 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:42,代碼來源:test_clipboard.py

示例14: _ensure_decoded

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import get_option [as 別名]
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 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:7,代碼來源:common.py

示例15: get_engine

# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import get_option [as 別名]
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() 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:32,代碼來源:parquet.py


注:本文中的pandas.get_option方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。