Skip to content

Commit

Permalink
DOC: Fixing EX01 - Added examples (#54168)
Browse files Browse the repository at this point in the history
Examples AccessorRegistrationWarning, AttributeConflictWarning, DataError
  • Loading branch information
DeaMariaLeon authored Jul 17, 2023
1 parent ab85d7a commit c539d1f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
3 changes: 0 additions & 3 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then

MSG='Partially validate docstrings (EX01)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01 --ignore_functions \
pandas.errors.AccessorRegistrationWarning \
pandas.errors.AttributeConflictWarning \
pandas.errors.DataError \
pandas.errors.IncompatibilityWarning \
pandas.errors.InvalidComparison \
pandas.errors.IntCastingNaNError \
Expand Down
1 change: 0 additions & 1 deletion doc/source/reference/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Exceptions and warnings
:toctree: api/

errors.AbstractMethodError
errors.AccessorRegistrationWarning
errors.AttributeConflictWarning
errors.CategoricalConversionWarning
errors.ChainedAssignmentError
Expand Down
25 changes: 18 additions & 7 deletions pandas/errors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,6 @@ class MergeError(ValueError):
"""


class AccessorRegistrationWarning(Warning):
"""
Warning for attribute conflicts in accessor registration.
"""


class AbstractMethodError(NotImplementedError):
"""
Raise this error instead of NotImplementedError for abstract methods.
Expand Down Expand Up @@ -281,6 +275,13 @@ class DataError(Exception):
For example, calling ``ohlc`` on a non-numerical column or a function
on a rolling window.
Examples
--------
>>> ser = pd.Series(['a', 'b', 'c'])
>>> ser.rolling(2).sum()
Traceback (most recent call last):
DataError: No numeric types to aggregate
"""


Expand Down Expand Up @@ -552,6 +553,17 @@ class AttributeConflictWarning(Warning):
Occurs when attempting to append an index with a different
name than the existing index on an HDFStore or attempting to append an index with a
different frequency than the existing index on an HDFStore.
Examples
--------
>>> idx1 = pd.Index(['a', 'b'], name='name1')
>>> df1 = pd.DataFrame([[1, 2], [3, 4]], index=idx1)
>>> df1.to_hdf('file', 'data', 'w', append=True) # doctest: +SKIP
>>> idx2 = pd.Index(['c', 'd'], name='name2')
>>> df2 = pd.DataFrame([[5, 6], [7, 8]], index=idx2)
>>> df2.to_hdf('file', 'data', 'a', append=True) # doctest: +SKIP
AttributeConflictWarning: the [index_name] attribute of the existing index is
[name1] which conflicts with the new [name2]...
"""


Expand Down Expand Up @@ -644,7 +656,6 @@ class InvalidComparison(Exception):

__all__ = [
"AbstractMethodError",
"AccessorRegistrationWarning",
"AttributeConflictWarning",
"CategoricalConversionWarning",
"ClosedFileError",
Expand Down

0 comments on commit c539d1f

Please sign in to comment.