-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -799,6 +799,18 @@ def is_(self, other) -> bool: | |
See Also | ||
-------- | ||
Index.identical : Works like ``Index.is_`` but also checks metadata. | ||
|
||
Examples | ||
-------- | ||
>>> idx1 = pd.Index(['1', '2', '3']) | ||
>>> idx2 = pd.Index(['1', '2', '3']) | ||
>>> idx2.is_(idx1) | ||
False | ||
|
||
>>> idx1 = pd.Index(['1', '2', '3']) | ||
>>> new_name = idx1 | ||
>>> new_name.is_(idx1) | ||
True | ||
""" | ||
if self is other: | ||
return True | ||
|
@@ -1089,6 +1101,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]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's green @MarcoGorelli |
||
Index(['c'], dtype='object') | ||
""" | ||
|
||
@Appender(_index_shared_docs["take"] % _index_doc_kwargs) | ||
|
@@ -2966,6 +2984,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) | ||
|
@@ -5345,6 +5369,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: | ||
|
@@ -5474,6 +5505,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) | ||
|
@@ -6694,6 +6737,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: | ||
|
@@ -6755,6 +6804,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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to make it clearer, maybe we could have an example like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done