Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 0 additions & 5 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01 --ignore_functions \
pandas.Series.backfill \
pandas.Series.pad \
pandas.DataFrame.sparse \
pandas.Series.attrs \
pandas.Series.plot \
pandas.Series.hist \
pandas.Series.to_string \
pandas.errors.AbstractMethodError \
pandas.errors.AccessorRegistrationWarning \
pandas.errors.AttributeConflictWarning \
pandas.errors.DataError \
Expand Down
7 changes: 7 additions & 0 deletions pandas/core/arrays/sparse/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,13 @@ def to_dense(self) -> Series:
class SparseFrameAccessor(BaseAccessor, PandasDelegate):
"""
DataFrame accessor for sparse data.

Examples
--------
>>> df = pd.DataFrame({"a": [1, 2, 0, 0],
... "b": [3, 0, 0, 4]}, dtype="Sparse[int]")
>>> df.sparse.density
0.5
"""

def _validate(self, data):
Expand Down
7 changes: 7 additions & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,13 @@ def attrs(self) -> dict[Hashable, Any]:
See Also
--------
DataFrame.flags : Global flags applying to this object.

Examples
--------
>>> ser = pd.Series([1, 2, 3])
>>> ser.attrs = {"A": [10, 20, 30]}
>>> ser.attrs
{'A': [10, 20, 30]}
"""
if self._attrs is None:
self._attrs = {}
Expand Down
6 changes: 6 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1713,6 +1713,12 @@ def to_string(
-------
str or None
String representation of Series if ``buf=None``, otherwise None.

Examples
--------
>>> ser = pd.Series([1, 2, 3]).to_string()
>>> ser
'0 1\\n1 2\\n2 3'
"""
formatter = fmt.SeriesFormatter(
self,
Expand Down
16 changes: 16 additions & 0 deletions pandas/errors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,22 @@ class AccessorRegistrationWarning(Warning):
class AbstractMethodError(NotImplementedError):
"""
Raise this error instead of NotImplementedError for abstract methods.

Examples
--------
>>> class Foo:
... @classmethod
... def classmethod(cls):
... raise pd.errors.AbstractMethodError(cls, methodtype="classmethod")
... def method(self):
... raise pd.errors.AbstractMethodError(self)
>>> test = Foo.classmethod()
Traceback (most recent call last):
AbstractMethodError: This classmethod must be defined in the concrete class Foo

>>> test2 = Foo().method()
Traceback (most recent call last):
AbstractMethodError: This classmethod must be defined in the concrete class Foo
"""

def __init__(self, class_instance, methodtype: str = "method") -> None:
Expand Down
9 changes: 9 additions & 0 deletions pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,15 @@ class PlotAccessor(PandasObject):
for bar plot layout by `position` keyword.
From 0 (left/bottom-end) to 1 (right/top-end). Default is 0.5
(center)

Examples
--------

.. plot::
:context: close-figs

>>> ser = pd.Series([1, 2, 3, 3])
>>> plot = ser.plot(kind='hist', title="My plot")
"""

_common_kinds = ("line", "bar", "barh", "kde", "density", "area", "hist", "box")
Expand Down