Python pandas.reset_option() Examples

The following are 30 code examples of pandas.reset_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_format.py    From recruit with Apache License 2.0 7 votes vote down vote up
def test_wide_repr(self):
        with option_context('mode.sim_interactive', True,
                            'display.show_dimensions', True,
                            'display.max_columns', 20):
            max_cols = get_option('display.max_columns')
            df = DataFrame(tm.rands_array(25, size=(10, max_cols - 1)))
            set_option('display.expand_frame_repr', False)
            rep_str = repr(df)

            assert "10 rows x {c} columns".format(c=max_cols - 1) in rep_str
            set_option('display.expand_frame_repr', True)
            wide_repr = repr(df)
            assert rep_str != wide_repr

            with option_context('display.width', 120):
                wider_repr = repr(df)
                assert len(wider_repr) < len(wide_repr)

        reset_option('display.expand_frame_repr') 
Example #2
Source File: dropna.py    From mars with Apache License 2.0 7 votes vote down vote up
def execute(cls, ctx, op: "DataFrameDropNA"):
        try:
            pd.set_option('mode.use_inf_as_na', op.use_inf_as_na)

            in_data = ctx[op.inputs[0].key]
            if op.drop_directly:
                if in_data.ndim == 2:
                    result = in_data.dropna(axis=op.axis, how=op.how, thresh=op.thresh,
                                            subset=op.subset)
                else:
                    result = in_data.dropna(axis=op.axis, how=op.how)
                ctx[op.outputs[0].key] = result
                return

            in_counts = ctx[op.inputs[1].key]
            if op.how == 'all':
                in_counts = in_counts[in_counts > 0]
            else:
                thresh = op.subset_size if op.thresh is None else op.thresh
                in_counts = in_counts[in_counts >= thresh]

            ctx[op.outputs[0].key] = in_data.reindex(in_counts.index)
        finally:
            pd.reset_option('mode.use_inf_as_na') 
Example #3
Source File: test_format.py    From twitter-stock-recommendation with MIT License 6 votes vote down vote up
def test_wide_repr_multiindex_cols(self):
        with option_context('mode.sim_interactive', True,
                            'display.max_columns', 20):
            max_cols = get_option('display.max_columns')
            midx = MultiIndex.from_arrays(tm.rands_array(5, size=(2, 10)))
            mcols = MultiIndex.from_arrays(
                tm.rands_array(3, size=(2, max_cols - 1)))
            df = DataFrame(tm.rands_array(25, (10, max_cols - 1)),
                           index=midx, columns=mcols)
            df.index.names = ['Level 0', 'Level 1']
            set_option('display.expand_frame_repr', False)
            rep_str = repr(df)
            set_option('display.expand_frame_repr', True)
            wide_repr = repr(df)
            assert rep_str != wide_repr

        with option_context('display.width', 150, 'display.max_columns', 20):
            wider_repr = repr(df)
            assert len(wider_repr) < len(wide_repr)

        reset_option('display.expand_frame_repr') 
Example #4
Source File: test_format.py    From twitter-stock-recommendation with MIT License 6 votes vote down vote up
def test_wide_repr_multiindex(self):
        with option_context('mode.sim_interactive', True,
                            'display.max_columns', 20):
            midx = MultiIndex.from_arrays(tm.rands_array(5, size=(2, 10)))
            max_cols = get_option('display.max_columns')
            df = DataFrame(tm.rands_array(25, size=(10, max_cols - 1)),
                           index=midx)
            df.index.names = ['Level 0', 'Level 1']
            set_option('display.expand_frame_repr', False)
            rep_str = repr(df)
            set_option('display.expand_frame_repr', True)
            wide_repr = repr(df)
            assert rep_str != wide_repr

            with option_context('display.width', 150):
                wider_repr = repr(df)
                assert len(wider_repr) < len(wide_repr)

            for line in wide_repr.splitlines()[1::13]:
                assert 'Level 0 Level 1' in line

        reset_option('display.expand_frame_repr') 
Example #5
Source File: test_format.py    From twitter-stock-recommendation with MIT License 6 votes vote down vote up
def test_wide_repr_named(self):
        with option_context('mode.sim_interactive', True,
                            'display.max_columns', 20):
            max_cols = get_option('display.max_columns')
            df = DataFrame(tm.rands_array(25, size=(10, max_cols - 1)))
            df.index.name = 'DataFrame Index'
            set_option('display.expand_frame_repr', False)

            rep_str = repr(df)
            set_option('display.expand_frame_repr', True)
            wide_repr = repr(df)
            assert rep_str != wide_repr

            with option_context('display.width', 150):
                wider_repr = repr(df)
                assert len(wider_repr) < len(wide_repr)

            for line in wide_repr.splitlines()[1::13]:
                assert 'DataFrame Index' in line

        reset_option('display.expand_frame_repr') 
Example #6
Source File: test_format.py    From twitter-stock-recommendation with MIT License 6 votes vote down vote up
def test_wide_repr(self):
        with option_context('mode.sim_interactive', True,
                            'display.show_dimensions', True,
                            'display.max_columns', 20):
            max_cols = get_option('display.max_columns')
            df = DataFrame(tm.rands_array(25, size=(10, max_cols - 1)))
            set_option('display.expand_frame_repr', False)
            rep_str = repr(df)

            assert "10 rows x {c} columns".format(c=max_cols - 1) in rep_str
            set_option('display.expand_frame_repr', True)
            wide_repr = repr(df)
            assert rep_str != wide_repr

            with option_context('display.width', 120):
                wider_repr = repr(df)
                assert len(wider_repr) < len(wide_repr)

        reset_option('display.expand_frame_repr') 
Example #7
Source File: test_format.py    From elasticintel with GNU General Public License v3.0 6 votes vote down vote up
def test_wide_repr_multiindex(self):
        with option_context('mode.sim_interactive', True):
            midx = MultiIndex.from_arrays(tm.rands_array(5, size=(2, 10)))
            max_cols = get_option('display.max_columns')
            df = DataFrame(tm.rands_array(25, size=(10, max_cols - 1)),
                           index=midx)
            df.index.names = ['Level 0', 'Level 1']
            set_option('display.expand_frame_repr', False)
            rep_str = repr(df)
            set_option('display.expand_frame_repr', True)
            wide_repr = repr(df)
            assert rep_str != wide_repr

            with option_context('display.width', 150):
                wider_repr = repr(df)
                assert len(wider_repr) < len(wide_repr)

            for line in wide_repr.splitlines()[1::13]:
                assert 'Level 0 Level 1' in line

        reset_option('display.expand_frame_repr') 
Example #8
Source File: test_format.py    From elasticintel with GNU General Public License v3.0 6 votes vote down vote up
def test_wide_repr_named(self):
        with option_context('mode.sim_interactive', True):
            max_cols = get_option('display.max_columns')
            df = DataFrame(tm.rands_array(25, size=(10, max_cols - 1)))
            df.index.name = 'DataFrame Index'
            set_option('display.expand_frame_repr', False)

            rep_str = repr(df)
            set_option('display.expand_frame_repr', True)
            wide_repr = repr(df)
            assert rep_str != wide_repr

            with option_context('display.width', 150):
                wider_repr = repr(df)
                assert len(wider_repr) < len(wide_repr)

            for line in wide_repr.splitlines()[1::13]:
                assert 'DataFrame Index' in line

        reset_option('display.expand_frame_repr') 
Example #9
Source File: test_format.py    From elasticintel with GNU General Public License v3.0 6 votes vote down vote up
def test_wide_repr(self):
        with option_context('mode.sim_interactive', True,
                            'display.show_dimensions', True):
            max_cols = get_option('display.max_columns')
            df = DataFrame(tm.rands_array(25, size=(10, max_cols - 1)))
            set_option('display.expand_frame_repr', False)
            rep_str = repr(df)

            assert "10 rows x %d columns" % (max_cols - 1) in rep_str
            set_option('display.expand_frame_repr', True)
            wide_repr = repr(df)
            assert rep_str != wide_repr

            with option_context('display.width', 120):
                wider_repr = repr(df)
                assert len(wider_repr) < len(wide_repr)

        reset_option('display.expand_frame_repr') 
Example #10
Source File: test_format.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 6 votes vote down vote up
def test_wide_repr_multiindex_cols(self):
        with option_context('mode.sim_interactive', True,
                            'display.max_columns', 20):
            max_cols = get_option('display.max_columns')
            midx = MultiIndex.from_arrays(tm.rands_array(5, size=(2, 10)))
            mcols = MultiIndex.from_arrays(
                tm.rands_array(3, size=(2, max_cols - 1)))
            df = DataFrame(tm.rands_array(25, (10, max_cols - 1)),
                           index=midx, columns=mcols)
            df.index.names = ['Level 0', 'Level 1']
            set_option('display.expand_frame_repr', False)
            rep_str = repr(df)
            set_option('display.expand_frame_repr', True)
            wide_repr = repr(df)
            assert rep_str != wide_repr

        with option_context('display.width', 150, 'display.max_columns', 20):
            wider_repr = repr(df)
            assert len(wider_repr) < len(wide_repr)

        reset_option('display.expand_frame_repr') 
Example #11
Source File: test_format.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 6 votes vote down vote up
def test_wide_repr_multiindex(self):
        with option_context('mode.sim_interactive', True,
                            'display.max_columns', 20):
            midx = MultiIndex.from_arrays(tm.rands_array(5, size=(2, 10)))
            max_cols = get_option('display.max_columns')
            df = DataFrame(tm.rands_array(25, size=(10, max_cols - 1)),
                           index=midx)
            df.index.names = ['Level 0', 'Level 1']
            set_option('display.expand_frame_repr', False)
            rep_str = repr(df)
            set_option('display.expand_frame_repr', True)
            wide_repr = repr(df)
            assert rep_str != wide_repr

            with option_context('display.width', 150):
                wider_repr = repr(df)
                assert len(wider_repr) < len(wide_repr)

            for line in wide_repr.splitlines()[1::13]:
                assert 'Level 0 Level 1' in line

        reset_option('display.expand_frame_repr') 
Example #12
Source File: test_format.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 6 votes vote down vote up
def test_wide_repr_named(self):
        with option_context('mode.sim_interactive', True,
                            'display.max_columns', 20):
            max_cols = get_option('display.max_columns')
            df = DataFrame(tm.rands_array(25, size=(10, max_cols - 1)))
            df.index.name = 'DataFrame Index'
            set_option('display.expand_frame_repr', False)

            rep_str = repr(df)
            set_option('display.expand_frame_repr', True)
            wide_repr = repr(df)
            assert rep_str != wide_repr

            with option_context('display.width', 150):
                wider_repr = repr(df)
                assert len(wider_repr) < len(wide_repr)

            for line in wide_repr.splitlines()[1::13]:
                assert 'DataFrame Index' in line

        reset_option('display.expand_frame_repr') 
Example #13
Source File: test_format.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 6 votes vote down vote up
def test_wide_repr(self):
        with option_context('mode.sim_interactive', True,
                            'display.show_dimensions', True,
                            'display.max_columns', 20):
            max_cols = get_option('display.max_columns')
            df = DataFrame(tm.rands_array(25, size=(10, max_cols - 1)))
            set_option('display.expand_frame_repr', False)
            rep_str = repr(df)

            assert "10 rows x {c} columns".format(c=max_cols - 1) in rep_str
            set_option('display.expand_frame_repr', True)
            wide_repr = repr(df)
            assert rep_str != wide_repr

            with option_context('display.width', 120):
                wider_repr = repr(df)
                assert len(wider_repr) < len(wide_repr)

        reset_option('display.expand_frame_repr') 
Example #14
Source File: stats_metrics.py    From fanci with GNU General Public License v3.0 6 votes vote down vote up
def write_to_html(self):
        pandas.set_option('display.max_colwidth', -1)
        header = '{!s}'.format(self.df.index.tolist()[0])
        df = self.df.reset_index(level=['Clf.', 'Set_Type', 'Eval.'])
        if '#Rep.' in df:
            df.drop('#Rep.', 1, inplace=True)

        df.drop('Eval.', 1, inplace=True)
        df.drop('Set_Size', 1, inplace=True)
        df.drop('Set_Type', 1, inplace=True)
        df.drop('f1', 1, inplace=True)
        df.drop('precision', 1, inplace=True)
        df.columns = ['Clf', '\\ac{DGA} Type', '\\ac{ACC}', '\\ac{TPR}', '\\ac{TNR}', '\\ac{FNR}', '\\ac{FPR}']
        fname = settings.ANALYSIS_FOLDER + '/eval_full.html'
        with open(fname, 'w') as f:
            f.write(df.to_html())
        pandas.reset_option('display.max_colwidth') 
Example #15
Source File: test_format.py    From vnpy_crypto with MIT License 6 votes vote down vote up
def test_wide_repr_multiindex_cols(self):
        with option_context('mode.sim_interactive', True,
                            'display.max_columns', 20):
            max_cols = get_option('display.max_columns')
            midx = MultiIndex.from_arrays(tm.rands_array(5, size=(2, 10)))
            mcols = MultiIndex.from_arrays(
                tm.rands_array(3, size=(2, max_cols - 1)))
            df = DataFrame(tm.rands_array(25, (10, max_cols - 1)),
                           index=midx, columns=mcols)
            df.index.names = ['Level 0', 'Level 1']
            set_option('display.expand_frame_repr', False)
            rep_str = repr(df)
            set_option('display.expand_frame_repr', True)
            wide_repr = repr(df)
            assert rep_str != wide_repr

        with option_context('display.width', 150, 'display.max_columns', 20):
            wider_repr = repr(df)
            assert len(wider_repr) < len(wide_repr)

        reset_option('display.expand_frame_repr') 
Example #16
Source File: test_format.py    From recruit with Apache License 2.0 6 votes vote down vote up
def test_wide_repr_named(self):
        with option_context('mode.sim_interactive', True,
                            'display.max_columns', 20):
            max_cols = get_option('display.max_columns')
            df = DataFrame(tm.rands_array(25, size=(10, max_cols - 1)))
            df.index.name = 'DataFrame Index'
            set_option('display.expand_frame_repr', False)

            rep_str = repr(df)
            set_option('display.expand_frame_repr', True)
            wide_repr = repr(df)
            assert rep_str != wide_repr

            with option_context('display.width', 150):
                wider_repr = repr(df)
                assert len(wider_repr) < len(wide_repr)

            for line in wide_repr.splitlines()[1::13]:
                assert 'DataFrame Index' in line

        reset_option('display.expand_frame_repr') 
Example #17
Source File: test_format.py    From recruit with Apache License 2.0 6 votes vote down vote up
def test_wide_repr_multiindex(self):
        with option_context('mode.sim_interactive', True,
                            'display.max_columns', 20):
            midx = MultiIndex.from_arrays(tm.rands_array(5, size=(2, 10)))
            max_cols = get_option('display.max_columns')
            df = DataFrame(tm.rands_array(25, size=(10, max_cols - 1)),
                           index=midx)
            df.index.names = ['Level 0', 'Level 1']
            set_option('display.expand_frame_repr', False)
            rep_str = repr(df)
            set_option('display.expand_frame_repr', True)
            wide_repr = repr(df)
            assert rep_str != wide_repr

            with option_context('display.width', 150):
                wider_repr = repr(df)
                assert len(wider_repr) < len(wide_repr)

            for line in wide_repr.splitlines()[1::13]:
                assert 'Level 0 Level 1' in line

        reset_option('display.expand_frame_repr') 
Example #18
Source File: test_format.py    From recruit with Apache License 2.0 6 votes vote down vote up
def test_wide_repr_multiindex_cols(self):
        with option_context('mode.sim_interactive', True,
                            'display.max_columns', 20):
            max_cols = get_option('display.max_columns')
            midx = MultiIndex.from_arrays(tm.rands_array(5, size=(2, 10)))
            mcols = MultiIndex.from_arrays(
                tm.rands_array(3, size=(2, max_cols - 1)))
            df = DataFrame(tm.rands_array(25, (10, max_cols - 1)),
                           index=midx, columns=mcols)
            df.index.names = ['Level 0', 'Level 1']
            set_option('display.expand_frame_repr', False)
            rep_str = repr(df)
            set_option('display.expand_frame_repr', True)
            wide_repr = repr(df)
            assert rep_str != wide_repr

        with option_context('display.width', 150, 'display.max_columns', 20):
            wider_repr = repr(df)
            assert len(wider_repr) < len(wide_repr)

        reset_option('display.expand_frame_repr') 
Example #19
Source File: test_format.py    From vnpy_crypto with MIT License 6 votes vote down vote up
def test_wide_repr_named(self):
        with option_context('mode.sim_interactive', True,
                            'display.max_columns', 20):
            max_cols = get_option('display.max_columns')
            df = DataFrame(tm.rands_array(25, size=(10, max_cols - 1)))
            df.index.name = 'DataFrame Index'
            set_option('display.expand_frame_repr', False)

            rep_str = repr(df)
            set_option('display.expand_frame_repr', True)
            wide_repr = repr(df)
            assert rep_str != wide_repr

            with option_context('display.width', 150):
                wider_repr = repr(df)
                assert len(wider_repr) < len(wide_repr)

            for line in wide_repr.splitlines()[1::13]:
                assert 'DataFrame Index' in line

        reset_option('display.expand_frame_repr') 
Example #20
Source File: test_format.py    From vnpy_crypto with MIT License 6 votes vote down vote up
def test_wide_repr(self):
        with option_context('mode.sim_interactive', True,
                            'display.show_dimensions', True,
                            'display.max_columns', 20):
            max_cols = get_option('display.max_columns')
            df = DataFrame(tm.rands_array(25, size=(10, max_cols - 1)))
            set_option('display.expand_frame_repr', False)
            rep_str = repr(df)

            assert "10 rows x {c} columns".format(c=max_cols - 1) in rep_str
            set_option('display.expand_frame_repr', True)
            wide_repr = repr(df)
            assert rep_str != wide_repr

            with option_context('display.width', 120):
                wider_repr = repr(df)
                assert len(wider_repr) < len(wide_repr)

        reset_option('display.expand_frame_repr') 
Example #21
Source File: aggregation.py    From mars with Apache License 2.0 6 votes vote down vote up
def execute(cls, ctx, op: "DataFrameAggregate"):
        try:
            pd.set_option('mode.use_inf_as_na', op.use_inf_as_na)
            if op.stage == OperandStage.map:
                cls._execute_map(ctx, op)
            elif op.stage == OperandStage.combine:
                cls._execute_combine(ctx, op)
            elif op.stage == OperandStage.agg:
                cls._execute_agg(ctx, op)
            elif op.raw_func == 'size':
                xp = cp if op.gpu else np
                ctx[op.outputs[0].key] = xp.array(ctx[op.inputs[0].key].agg(op.raw_func, axis=op.axis)) \
                    .reshape(op.outputs[0].shape)
            else:
                ctx[op.outputs[0].key] = ctx[op.inputs[0].key].agg(op.raw_func, axis=op.axis)
        finally:
            pd.reset_option('mode.use_inf_as_na') 
Example #22
Source File: fillna.py    From mars with Apache License 2.0 6 votes vote down vote up
def execute(cls, ctx, op):
        try:
            pd.set_option('mode.use_inf_as_na', op.use_inf_as_na)
            if op.stage == OperandStage.map:
                cls._execute_map(ctx, op)
            elif op.stage == OperandStage.combine:
                cls._execute_combine(ctx, op)
            else:
                input_data = ctx[op.inputs[0].key]
                value = getattr(op, 'value', None)
                if isinstance(op.value, (Base, Entity)):
                    value = ctx[op.value.key]
                ctx[op.outputs[0].key] = input_data.fillna(
                    value=value, method=op.method, axis=op.axis, limit=op.limit, downcast=op.downcast)
        finally:
            pd.reset_option('mode.use_inf_as_na') 
Example #23
Source File: test_format.py    From vnpy_crypto with MIT License 6 votes vote down vote up
def test_wide_repr_multiindex(self):
        with option_context('mode.sim_interactive', True,
                            'display.max_columns', 20):
            midx = MultiIndex.from_arrays(tm.rands_array(5, size=(2, 10)))
            max_cols = get_option('display.max_columns')
            df = DataFrame(tm.rands_array(25, size=(10, max_cols - 1)),
                           index=midx)
            df.index.names = ['Level 0', 'Level 1']
            set_option('display.expand_frame_repr', False)
            rep_str = repr(df)
            set_option('display.expand_frame_repr', True)
            wide_repr = repr(df)
            assert rep_str != wide_repr

            with option_context('display.width', 150):
                wider_repr = repr(df)
                assert len(wider_repr) < len(wide_repr)

            for line in wide_repr.splitlines()[1::13]:
                assert 'Level 0 Level 1' in line

        reset_option('display.expand_frame_repr') 
Example #24
Source File: main.py    From yelp with GNU Lesser General Public License v2.1 5 votes vote down vote up
def dataset_bucket_analysis_by_field(field):
    # Set the dataset
    hotel_dataset_properties = {Constants.BUSINESS_TYPE_FIELD: 'fourcity_hotel'}
    Constants.update_properties(hotel_dataset_properties)

    records = ETLUtils.load_json_file(Constants.PROCESSED_RECORDS_FILE)

    print('Loaded %d records' % len(records))

    user_frequency_map = {}

    for record in records:

        user_id = record[field]
        if user_id not in user_frequency_map:
            user_frequency_map[user_id] = 0
        user_frequency_map[user_id] += 1

    print('There is a total of %d %ss' % (len(user_frequency_map), field))
    sorted_x = sorted(user_frequency_map.items(), key=operator.itemgetter(1), reverse=True)
    print(sorted_x[0])
    print(sorted_x[1])
    print(sorted_x[2])
    # print(user_frequency_map)

    # Number of reviews per user
    rda = ReviewsDatasetAnalyzer(records)
    users_summary = rda.summarize_reviews_by_field(field)
    print('Average number of reviews per %s: %f' % (field,
          float(rda.num_reviews) / rda.num_users))
    users_summary.plot(kind='line', rot=0)

    pandas.set_option('display.max_rows', len(users_summary))
    print(users_summary)
    pandas.reset_option('display.max_rows')

    # print(users_summary)
    # plt.show() 
Example #25
Source File: test_format.py    From recruit with Apache License 2.0 5 votes vote down vote up
def test_repr_chop_threshold(self):
        df = DataFrame([[0.1, 0.5], [0.5, -0.1]])
        pd.reset_option("display.chop_threshold")  # default None
        assert repr(df) == '     0    1\n0  0.1  0.5\n1  0.5 -0.1'

        with option_context("display.chop_threshold", 0.2):
            assert repr(df) == '     0    1\n0  0.0  0.5\n1  0.5  0.0'

        with option_context("display.chop_threshold", 0.6):
            assert repr(df) == '     0    1\n0  0.0  0.0\n1  0.0  0.0'

        with option_context("display.chop_threshold", None):
            assert repr(df) == '     0    1\n0  0.1  0.5\n1  0.5 -0.1' 
Example #26
Source File: test_format.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_repr_chop_threshold(self):
        df = DataFrame([[0.1, 0.5], [0.5, -0.1]])
        pd.reset_option("display.chop_threshold")  # default None
        assert repr(df) == '     0    1\n0  0.1  0.5\n1  0.5 -0.1'

        with option_context("display.chop_threshold", 0.2):
            assert repr(df) == '     0    1\n0  0.0  0.5\n1  0.5  0.0'

        with option_context("display.chop_threshold", 0.6):
            assert repr(df) == '     0    1\n0  0.0  0.0\n1  0.0  0.0'

        with option_context("display.chop_threshold", None):
            assert repr(df) == '     0    1\n0  0.1  0.5\n1  0.5 -0.1' 
Example #27
Source File: testing.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def reset_display_options():
    """
    Reset the display options for printing and representing objects.
    """

    pd.reset_option('^display.', silent=True) 
Example #28
Source File: test_format.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def test_wide_repr_unicode(self):
        with option_context('mode.sim_interactive', True):
            max_cols = get_option('display.max_columns')
            df = DataFrame(tm.rands_array(25, size=(10, max_cols - 1)))
            set_option('display.expand_frame_repr', False)
            rep_str = repr(df)
            set_option('display.expand_frame_repr', True)
            wide_repr = repr(df)
            assert rep_str != wide_repr

            with option_context('display.width', 150):
                wider_repr = repr(df)
                assert len(wider_repr) < len(wide_repr)

        reset_option('display.expand_frame_repr') 
Example #29
Source File: testing.py    From recruit with Apache License 2.0 5 votes vote down vote up
def reset_display_options():
    """
    Reset the display options for printing and representing objects.
    """

    pd.reset_option('^display.', silent=True) 
Example #30
Source File: checkna.py    From mars with Apache License 2.0 5 votes vote down vote up
def execute(cls, ctx, op: "DataFrameCheckNA"):
        in_data = ctx[op.inputs[0].key]
        try:
            pd.set_option('mode.use_inf_as_na', op.use_inf_as_na)
            if op.positive:
                ctx[op.outputs[0].key] = in_data.isna()
            else:
                ctx[op.outputs[0].key] = in_data.notna()
        finally:
            pd.reset_option('mode.use_inf_as_na')