Skip to content

DOC: fixed Ex03 errors in docstrings: #56878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.PossibleDataLossError \
pandas.errors.PossiblePrecisionLoss \
pandas.errors.SettingWithCopyError \
Expand Down
37 changes: 29 additions & 8 deletions pandas/errors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------
:attr:`.pandas.DataFrame.iloc` : Purely integer-location based indexing for \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think in the See Also section we need those :attr: markers, I think just DataFrame.iloc should render correctly. Same for the other cases in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Marc,

Thanks! I pushed these changes up.

selection by position.
:attr:`.pandas.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
"""

Expand Down Expand Up @@ -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
--------
:func:`.pandas.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
"""

Expand Down Expand Up @@ -758,10 +775,14 @@ class InvalidColumnName(Warning):
Because the column name is an invalid Stata variable, the name needs to be
converted.

See Also
--------
:meth:`.pandas.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...
"""

Expand Down