From 1f3dce4124d7708b5062a1594b5e99e316ee826b Mon Sep 17 00:00:00 2001 From: sunlight798 <3281498087@qq.com> Date: Sun, 8 Dec 2024 10:32:15 +0800 Subject: [PATCH 1/2] DOC: Fix docstrings for errors --- ci/code_checks.sh | 3 --- pandas/errors/__init__.py | 22 ++++++++++++++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index adc5bc9a01bdd..7bc220acdd74c 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -95,9 +95,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.core.resample.Resampler.std SA01" \ -i "pandas.core.resample.Resampler.transform PR01,RT03,SA01" \ -i "pandas.core.resample.Resampler.var SA01" \ - -i "pandas.errors.NullFrequencyError SA01" \ - -i "pandas.errors.NumbaUtilError SA01" \ - -i "pandas.errors.PerformanceWarning SA01" \ -i "pandas.errors.UndefinedVariableError PR01,SA01" \ -i "pandas.errors.ValueLabelTypeMismatch SA01" \ -i "pandas.io.json.build_table_schema PR07,RT03,SA01" \ diff --git a/pandas/errors/__init__.py b/pandas/errors/__init__.py index 1de6f06ef316c..8396df9761cbf 100644 --- a/pandas/errors/__init__.py +++ b/pandas/errors/__init__.py @@ -45,6 +45,11 @@ class NullFrequencyError(ValueError): Particularly ``DatetimeIndex.shift``, ``TimedeltaIndex.shift``, ``PeriodIndex.shift``. + See Also + -------- + Index.shift : Shift values of Index. + Series.shift : Shift values of Series. + Examples -------- >>> df = pd.DatetimeIndex(["2011-01-01 10:00", "2011-01-01"], freq=None) @@ -58,6 +63,12 @@ class PerformanceWarning(Warning): """ Warning raised when there is a possible performance impact. + See Also + -------- + DataFrame.set_index : Set the DataFrame index using existing columns. + DataFrame.loc : Access a group of rows and columns by label(s) \ + or a boolean array. + Examples -------- >>> df = pd.DataFrame( @@ -385,6 +396,13 @@ class NumbaUtilError(Exception): """ Error raised for unsupported Numba engine routines. + See Also + -------- + DataFrame.groupby : Group DataFrame using a mapper or by a Series of columns. + Series.groupby : Group Series using a mapper or by a Series of columns. + DataFrame.agg : Aggregate using one or more operations over the specified axis. + Series.agg : Aggregate using one or more operations over the specified axis. + Examples -------- >>> df = pd.DataFrame( @@ -392,10 +410,10 @@ class NumbaUtilError(Exception): ... ) >>> def incorrect_function(x): ... return sum(x) * 2.7 - >>> df.groupby("key").agg(incorrect_function, engine="numba") + >>> df.("key").agg(incorrect_function, engine="numba") Traceback (most recent call last): NumbaUtilError: The first 2 arguments to incorrect_function - must be ['values', 'index'] + must be ['values', 'index']groupby """ From ec50b5a754659314877915c83ada7125aed3b7fb Mon Sep 17 00:00:00 2001 From: sunlight798 <3281498087@qq.com> Date: Sun, 8 Dec 2024 10:38:26 +0800 Subject: [PATCH 2/2] DOC: Fix docstrings for errors --- pandas/errors/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/errors/__init__.py b/pandas/errors/__init__.py index 8396df9761cbf..cd31ec30522c3 100644 --- a/pandas/errors/__init__.py +++ b/pandas/errors/__init__.py @@ -410,10 +410,10 @@ class NumbaUtilError(Exception): ... ) >>> def incorrect_function(x): ... return sum(x) * 2.7 - >>> df.("key").agg(incorrect_function, engine="numba") + >>> df.groupby("key").agg(incorrect_function, engine="numba") Traceback (most recent call last): NumbaUtilError: The first 2 arguments to incorrect_function - must be ['values', 'index']groupby + must be ['values', 'index'] """