本文整理匯總了Python中pandas.reset_option方法的典型用法代碼示例。如果您正苦於以下問題:Python pandas.reset_option方法的具體用法?Python pandas.reset_option怎麽用?Python pandas.reset_option使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pandas
的用法示例。
在下文中一共展示了pandas.reset_option方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_wide_repr
# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import reset_option [as 別名]
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')
示例2: test_wide_repr_named
# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import reset_option [as 別名]
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')
示例3: test_wide_repr_multiindex
# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import reset_option [as 別名]
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')
示例4: test_wide_repr_multiindex_cols
# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import reset_option [as 別名]
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')
示例5: execute
# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import reset_option [as 別名]
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')
示例6: execute
# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import reset_option [as 別名]
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')
示例7: execute
# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import reset_option [as 別名]
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')
示例8: write_to_html
# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import reset_option [as 別名]
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')
示例9: test_wide_repr
# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import reset_option [as 別名]
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')
示例10: test_wide_repr_named
# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import reset_option [as 別名]
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')
示例11: test_wide_repr_multiindex
# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import reset_option [as 別名]
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')
示例12: test_repr_chop_threshold
# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import reset_option [as 別名]
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'
示例13: reset_display_options
# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import reset_option [as 別名]
def reset_display_options():
"""
Reset the display options for printing and representing objects.
"""
pd.reset_option('^display.', silent=True)
示例14: execute
# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import reset_option [as 別名]
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')
示例15: execute
# 需要導入模塊: import pandas [as 別名]
# 或者: from pandas import reset_option [as 別名]
def execute(cls, ctx, op):
try:
pd.set_option('mode.use_inf_as_na', op.use_inf_as_na)
if op.stage == OperandStage.combine:
cls._execute_combine(ctx, op)
elif op.stage == OperandStage.agg:
cls._execute_agg(ctx, op)
elif op.stage == OperandStage.map:
cls._execute_map(ctx, op)
else:
in_data = ctx[op.inputs[0].key]
min_count = getattr(op, 'min_count', None)
ctx[op.outputs[0].key] = cls._execute_reduction(in_data, op, min_count)
finally:
pd.reset_option('mode.use_inf_as_na')