From 76f945c37948a64418028903497ac49ce269e16f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dea=20Mar=C3=ADa=20L=C3=A9on?= Date: Fri, 30 Jun 2023 13:11:42 +0200 Subject: [PATCH] Examples options --- ci/code_checks.sh | 4 ---- pandas/_config/config.py | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index cc7c64f001809..09ad695715078 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -126,10 +126,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.core.resample.Resampler.sum \ pandas.core.resample.Resampler.var \ pandas.core.resample.Resampler.quantile \ - pandas.describe_option \ - pandas.reset_option \ - pandas.get_option \ - pandas.set_option \ pandas.plotting.deregister_matplotlib_converters \ pandas.plotting.plot_params \ pandas.plotting.register_matplotlib_converters \ diff --git a/pandas/_config/config.py b/pandas/_config/config.py index 33e5ac8d2a26c..9caeaadc1ad84 100644 --- a/pandas/_config/config.py +++ b/pandas/_config/config.py @@ -300,6 +300,11 @@ def __doc__(self) -> str: # type: ignore[override] The available options with its descriptions: {opts_desc} + +Examples +-------- +>>> pd.get_option('display.max_columns') # doctest: +SKIP +4 """ _set_option_tmpl = """ @@ -336,6 +341,17 @@ def __doc__(self) -> str: # type: ignore[override] The available options with its descriptions: {opts_desc} + +Examples +-------- +>>> pd.set_option('display.max_columns', 4) +>>> df = pd.DataFrame([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]) +>>> df + 0 1 ... 3 4 +0 1 2 ... 4 5 +1 6 7 ... 9 10 +[2 rows x 5 columns] +>>> pd.reset_option('display.max_columns') """ _describe_option_tmpl = """ @@ -370,6 +386,12 @@ def __doc__(self) -> str: # type: ignore[override] The available options with its descriptions: {opts_desc} + +Examples +-------- +>>> pd.describe_option('display.max_columns') # doctest: +SKIP +display.max_columns : int + If max_cols is exceeded, switch to truncate view... """ _reset_option_tmpl = """ @@ -402,6 +424,10 @@ def __doc__(self) -> str: # type: ignore[override] The available options with its descriptions: {opts_desc} + +Examples +-------- +>>> pd.reset_option('display.max_columns') # doctest: +SKIP """ # bind the functions with their docstrings into a Callable