diff --git a/ci/code_checks.sh b/ci/code_checks.sh index f27dbeaf35915..bdd38bda2dfc0 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -73,9 +73,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then $BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX03 --ignore_functions \ pandas.Series.plot.line \ pandas.Series.to_sql \ - pandas.errors.DatabaseError \ - pandas.errors.IndexingError \ - pandas.errors.InvalidColumnName \ pandas.errors.SettingWithCopyWarning \ pandas.errors.SpecificationError \ pandas.errors.UndefinedVariableError \ diff --git a/pandas/errors/__init__.py b/pandas/errors/__init__.py index 9d39b8d92fec9..3cda1273d4ae7 100644 --- a/pandas/errors/__init__.py +++ b/pandas/errors/__init__.py @@ -599,19 +599,30 @@ class IndexingError(Exception): """ Exception is raised when trying to index and there is a mismatch in dimensions. + Raised by properties like :attr:`.pandas.DataFrame.iloc` when + an indexer is out of bounds or :attr:`.pandas.DataFrame.loc` when its index is + unalignable to the frame index. + + See Also + -------- + DataFrame.iloc : Purely integer-location based indexing for \ + selection by position. + DataFrame.loc : Access a group of rows and columns by label(s) \ + or a boolean array. + Examples -------- >>> df = pd.DataFrame({'A': [1, 1, 1]}) - >>> df.loc[..., ..., 'A'] # doctest: +SKIP + >>> df.loc[..., ..., 'A'] # doctest: +SKIP ... # IndexingError: indexer may only contain one '...' entry >>> df = pd.DataFrame({'A': [1, 1, 1]}) - >>> df.loc[1, ..., ...] # doctest: +SKIP + >>> df.loc[1, ..., ...] # doctest: +SKIP ... # IndexingError: Too many indexers - >>> df[pd.Series([True], dtype=bool)] # doctest: +SKIP + >>> df[pd.Series([True], dtype=bool)] # doctest: +SKIP ... # IndexingError: Unalignable boolean Series provided as indexer... >>> s = pd.Series(range(2), - ... index = pd.MultiIndex.from_product([["a", "b"], ["c"]])) - >>> s.loc["a", "c", "d"] # doctest: +SKIP + ... index=pd.MultiIndex.from_product([["a", "b"], ["c"]])) + >>> s.loc["a", "c", "d"] # doctest: +SKIP ... # IndexingError: Too many indexers """ @@ -713,13 +724,19 @@ class AttributeConflictWarning(Warning): class DatabaseError(OSError): """ - Error is raised when executing sql with bad syntax or sql that throws an error. + Error is raised when executing SQL with bad syntax or SQL that throws an error. + + Raised by :func:`.pandas.read_sql` when a bad SQL statement is passed in. + + See Also + -------- + read_sql : Read SQL query or database table into a DataFrame. Examples -------- >>> from sqlite3 import connect >>> conn = connect(':memory:') - >>> pd.read_sql('select * test', conn) # doctest: +SKIP + >>> pd.read_sql('select * test', conn) # doctest: +SKIP ... # DatabaseError: Execution failed on sql 'test': near "test": syntax error """ @@ -758,10 +775,14 @@ class InvalidColumnName(Warning): Because the column name is an invalid Stata variable, the name needs to be converted. + See Also + -------- + DataFrame.to_stata : Export DataFrame object to Stata dta format. + Examples -------- >>> df = pd.DataFrame({"0categories": pd.Series([2, 2])}) - >>> df.to_stata('test') # doctest: +SKIP + >>> df.to_stata('test') # doctest: +SKIP ... # InvalidColumnName: Not all pandas column names were valid Stata variable... """