Skip to content

Commit 4f55280

Browse files
authored
DOC: Fixing EX01 - Added examples (pandas-dev#54266)
Examples ExtensionArray, hash_array ...
1 parent e35916d commit 4f55280

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

ci/code_checks.sh

+2-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
6464
MSG='Partially validate docstrings (EX01)' ; echo $MSG
6565
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01 --ignore_functions \
6666
pandas.errors.IncompatibilityWarning \
67-
pandas.errors.NoBufferPresent \
6867
pandas.errors.OptionError \
6968
pandas.errors.PerformanceWarning \
7069
pandas.errors.PyperclipException \
@@ -78,13 +77,14 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7877
pandas.io.stata.StataWriter.write_file \
7978
pandas.plotting.deregister_matplotlib_converters \
8079
pandas.plotting.register_matplotlib_converters \
80+
pandas.api.indexers.BaseIndexer \
81+
pandas.api.indexers.VariableOffsetWindowIndexer \
8182
pandas.util.hash_array \
8283
pandas.util.hash_pandas_object \
8384
pandas_object \
8485
pandas.api.extensions.ExtensionDtype \
8586
pandas.api.extensions.ExtensionArray \
8687
pandas.arrays.NumpyExtensionArray \
87-
pandas.api.extensions.ExtensionArray._concat_same_type \
8888
pandas.api.extensions.ExtensionArray._formatter \
8989
pandas.api.extensions.ExtensionArray._from_factorized \
9090
pandas.api.extensions.ExtensionArray._from_sequence \
@@ -93,7 +93,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
9393
pandas.api.extensions.ExtensionArray._reduce \
9494
pandas.api.extensions.ExtensionArray._values_for_factorize \
9595
pandas.api.extensions.ExtensionArray.interpolate \
96-
pandas.api.extensions.ExtensionArray.ravel \
9796
RET=$(($RET + $?)) ; echo $MSG "DONE"
9897

9998
fi

pandas/core/arrays/base.py

+16
Original file line numberDiff line numberDiff line change
@@ -1565,6 +1565,13 @@ def ravel(self, order: Literal["C", "F", "A", "K"] | None = "C") -> ExtensionArr
15651565
-----
15661566
- Because ExtensionArrays are 1D-only, this is a no-op.
15671567
- The "order" argument is ignored, is for compatibility with NumPy.
1568+
1569+
Examples
1570+
--------
1571+
>>> pd.array([1, 2, 3]).ravel()
1572+
<IntegerArray>
1573+
[1, 2, 3]
1574+
Length: 3, dtype: Int64
15681575
"""
15691576
return self
15701577

@@ -1580,6 +1587,15 @@ def _concat_same_type(cls, to_concat: Sequence[Self]) -> Self:
15801587
Returns
15811588
-------
15821589
ExtensionArray
1590+
1591+
Examples
1592+
--------
1593+
>>> arr1 = pd.array([1, 2, 3])
1594+
>>> arr2 = pd.array([4, 5, 6])
1595+
>>> pd.arrays.IntegerArray._concat_same_type([arr1, arr2])
1596+
<IntegerArray>
1597+
[1, 2, 3, 4, 5, 6]
1598+
Length: 6, dtype: Int64
15831599
"""
15841600
# Implementer note: this method will only be called with a sequence of
15851601
# ExtensionArrays of this class and with the same dtype as self. This

pandas/core/util/hashing.py

+14
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ def hash_pandas_object(
106106
Returns
107107
-------
108108
Series of uint64, same length as the object
109+
110+
Examples
111+
--------
112+
>>> pd.util.hash_pandas_object(pd.Series([1, 2, 3]))
113+
0 14639053686158035780
114+
1 3869563279212530728
115+
2 393322362522515241
116+
dtype: uint64
109117
"""
110118
from pandas import Series
111119

@@ -246,6 +254,12 @@ def hash_array(
246254
-------
247255
ndarray[np.uint64, ndim=1]
248256
Hashed values, same length as the vals.
257+
258+
Examples
259+
--------
260+
>>> pd.util.hash_array(np.array([1, 2, 3]))
261+
array([ 6238072747940578789, 15839785061582574730, 2185194620014831856],
262+
dtype=uint64)
249263
"""
250264
if not hasattr(vals, "dtype"):
251265
raise TypeError("must pass a ndarray-like")

scripts/validate_docstrings.py

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"Styler.loader",
5252
"errors.InvalidComparison",
5353
"errors.LossySetitemError",
54+
"errors.NoBufferPresent",
5455
}
5556
PRIVATE_CLASSES = ["NDFrame", "IndexOpsMixin"]
5657
ERROR_MSGS = {

0 commit comments

Comments
 (0)