Skip to content

Commit 498c438

Browse files
authored
DOC: Fixing EX01 - Added examples (#54277)
Examples ExtensionArray._from_factorized, _from_sequence ...
1 parent 577bb72 commit 498c438

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

ci/code_checks.sh

-9
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
6363

6464
MSG='Partially validate docstrings (EX01)' ; echo $MSG
6565
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01 --ignore_functions \
66-
pandas.errors.IncompatibilityWarning \
67-
pandas.errors.OptionError \
6866
pandas.errors.PerformanceWarning \
6967
pandas.errors.PyperclipException \
7068
pandas.errors.PyperclipWindowsException \
@@ -77,16 +75,9 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7775
pandas.io.stata.StataWriter.write_file \
7876
pandas.plotting.deregister_matplotlib_converters \
7977
pandas.plotting.register_matplotlib_converters \
80-
pandas.api.indexers.BaseIndexer \
81-
pandas.api.indexers.VariableOffsetWindowIndexer \
82-
pandas.util.hash_array \
83-
pandas.util.hash_pandas_object \
84-
pandas_object \
8578
pandas.api.extensions.ExtensionDtype \
8679
pandas.api.extensions.ExtensionArray \
8780
pandas.arrays.NumpyExtensionArray \
88-
pandas.api.extensions.ExtensionArray._from_factorized \
89-
pandas.api.extensions.ExtensionArray._from_sequence \
9081
pandas.api.extensions.ExtensionArray._from_sequence_of_strings \
9182
pandas.api.extensions.ExtensionArray._hash_pandas_object \
9283
pandas.api.extensions.ExtensionArray._reduce \

pandas/_config/config.py

+6
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ class OptionError(AttributeError, KeyError):
111111
Exception raised for pandas.options.
112112
113113
Backwards compatible with KeyError checks.
114+
115+
Examples
116+
--------
117+
>>> pd.options.context
118+
Traceback (most recent call last):
119+
OptionError: No such option
114120
"""
115121

116122

pandas/core/arrays/base.py

+17
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,13 @@ def _from_sequence(cls, scalars, *, dtype: Dtype | None = None, copy: bool = Fal
270270
Returns
271271
-------
272272
ExtensionArray
273+
274+
Examples
275+
--------
276+
>>> pd.arrays.IntegerArray._from_sequence([4, 5])
277+
<IntegerArray>
278+
[4, 5]
279+
Length: 2, dtype: Int64
273280
"""
274281
raise AbstractMethodError(cls)
275282

@@ -313,6 +320,16 @@ def _from_factorized(cls, values, original):
313320
--------
314321
factorize : Top-level factorize method that dispatches here.
315322
ExtensionArray.factorize : Encode the extension array as an enumerated type.
323+
324+
Examples
325+
--------
326+
>>> interv_arr = pd.arrays.IntervalArray([pd.Interval(0, 1),
327+
... pd.Interval(1, 5), pd.Interval(1, 5)])
328+
>>> codes, uniques = pd.factorize(interv_arr)
329+
>>> pd.arrays.IntervalArray._from_factorized(uniques, interv_arr)
330+
<IntervalArray>
331+
[(0, 1], (1, 5]]
332+
Length: 2, dtype: interval[int64, right]
316333
"""
317334
raise AbstractMethodError(cls)
318335

scripts/validate_docstrings.py

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"errors.InvalidComparison",
5353
"errors.LossySetitemError",
5454
"errors.NoBufferPresent",
55+
"errors.IncompatibilityWarning",
5556
}
5657
PRIVATE_CLASSES = ["NDFrame", "IndexOpsMixin"]
5758
ERROR_MSGS = {

0 commit comments

Comments
 (0)