Skip to content

DOC: Fixing EX01 - Added examples #53352

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 4 commits into from
May 24, 2023
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
7 changes: 0 additions & 7 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas.util.hash_pandas_object \
pandas_object \
pandas.api.interchange.from_dataframe \
pandas.Index.drop \
pandas.Index.identical \
pandas.Index.insert \
pandas.Index.is_ \
pandas.Index.take \
pandas.Index.putmask \
pandas.Index.unique \
pandas.Index.fillna \
pandas.Index.dropna \
pandas.Index.astype \
Expand Down
52 changes: 52 additions & 0 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,15 @@ def is_(self, other) -> bool:
See Also
--------
Index.identical : Works like ``Index.is_`` but also checks metadata.

Examples
--------
>>> idx1 = pd.Index(['1', '2', '3'])
>>> idx1.is_(idx1.view())
True

>>> idx1.is_(idx1.copy())
False
"""
if self is other:
return True
Expand Down Expand Up @@ -1089,6 +1098,12 @@ def astype(self, dtype, copy: bool = True):
--------
numpy.ndarray.take: Return an array formed from the
elements of a at the given indices.

Examples
--------
>>> idx = pd.Index(['a', 'b', 'c'])
>>> idx.take([2, 2, 1, 2])
Index(['c', 'c', 'b', 'c'], dtype='object')
"""

@Appender(_index_shared_docs["take"] % _index_doc_kwargs)
Expand Down Expand Up @@ -2966,6 +2981,12 @@ def unique(self, level: Hashable | None = None) -> Self:
--------
unique : Numpy array of unique values in that column.
Series.unique : Return unique values of Series object.

Examples
--------
>>> idx = pd.Index([1, 1, 2, 3, 3])
>>> idx.unique()
Index([1, 2, 3], dtype='int64')
"""
if level is not None:
self._validate_index_level(level)
Expand Down Expand Up @@ -5345,6 +5366,13 @@ def putmask(self, mask, value) -> Index:
--------
numpy.ndarray.putmask : Changes elements of an array
based on conditional and input values.

Examples
--------
>>> idx1 = pd.Index([1, 2, 3])
>>> idx2 = pd.Index([5, 6, 7])
>>> idx1.putmask([True, False, False], idx2)
Index([5, 2, 3], dtype='int64')
"""
mask, noop = validate_putmask(self._values, mask)
if noop:
Expand Down Expand Up @@ -5474,6 +5502,18 @@ def identical(self, other) -> bool:
bool
If two Index objects have equal elements and same type True,
otherwise False.

Examples
--------
>>> idx1 = pd.Index(['1', '2', '3'])
>>> idx2 = pd.Index(['1', '2', '3'])
>>> idx2.identical(idx1)
True

>>> idx1 = pd.Index(['1', '2', '3'], name="A")
>>> idx2 = pd.Index(['1', '2', '3'], name="B")
>>> idx2.identical(idx1)
False
"""
return (
self.equals(other)
Expand Down Expand Up @@ -6694,6 +6734,12 @@ def insert(self, loc: int, item) -> Index:
Returns
-------
Index

Examples
--------
>>> idx = pd.Index(['a', 'b', 'c'])
>>> idx.insert(1, 'x')
Index(['a', 'x', 'b', 'c'], dtype='object')
"""
item = lib.item_from_zerodim(item)
if is_valid_na_for_dtype(item, self.dtype) and self.dtype != object:
Expand Down Expand Up @@ -6755,6 +6801,12 @@ def drop(
------
KeyError
If not all of the labels are found in the selected axis

Examples
--------
>>> idx = pd.Index(['a', 'b', 'c'])
>>> idx.drop(['a'])
Index(['b', 'c'], dtype='object')
"""
if not isinstance(labels, Index):
# avoid materializing e.g. RangeIndex
Expand Down