-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC Fixing EX01 - added examples #53181
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
fe105a7
fc9e863
4883715
9152002
6834b8c
a9ca369
07a10c8
1f1418e
f119593
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 |
---|---|---|
|
@@ -357,12 +357,24 @@ def item(self): | |
Returns | ||
------- | ||
scalar | ||
The first element of Series. | ||
The first element of Series or Index. | ||
|
||
Raises | ||
------ | ||
ValueError | ||
If the data is not length-1. | ||
If the data is not length = 1. | ||
|
||
Examples | ||
-------- | ||
>>> s = pd.Series([1]) | ||
>>> s.item() | ||
1 | ||
|
||
For an index: | ||
|
||
>>> s = pd.Series([1], index=['a']) | ||
>>> s.index.item() | ||
'a' | ||
""" | ||
if len(self) == 1: | ||
return next(iter(self)) | ||
|
@@ -965,6 +977,12 @@ def is_unique(self) -> bool: | |
Returns | ||
------- | ||
bool | ||
|
||
Examples | ||
-------- | ||
>>> s = pd.Series([1, 2, 3, 1]) | ||
>>> s.is_unique | ||
False | ||
""" | ||
return self.nunique(dropna=False) == len(self) | ||
|
||
|
@@ -976,6 +994,12 @@ def is_monotonic_increasing(self) -> bool: | |
Returns | ||
------- | ||
bool | ||
|
||
Examples | ||
-------- | ||
>>> s = pd.Series([1, 2, 2]) | ||
>>> s.is_monotonic_increasing | ||
True | ||
""" | ||
from pandas import Index | ||
|
||
|
@@ -989,6 +1013,12 @@ def is_monotonic_decreasing(self) -> bool: | |
Returns | ||
------- | ||
bool | ||
|
||
Examples | ||
-------- | ||
>>> s = pd.Series([3, 2, 2, 1]) | ||
>>> s.is_monotonic_decreasing | ||
Comment on lines
+1027
to
+1028
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. for this and the above, could we add an example for when the return value is In general, for functions which return 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, thanks for the instructions. |
||
True | ||
""" | ||
from pandas import Index | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1170,13 +1170,43 @@ def cov( | |
return result | ||
|
||
@property | ||
@doc(Series.is_monotonic_increasing.__doc__) | ||
def is_monotonic_increasing(self) -> Series: | ||
# GH13 | ||
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. Yeah we don't need this (and below) 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. Thanks, I'll remove them. |
||
""" | ||
Return boolean if values in the group are monotonically increasing. | ||
|
||
Returns | ||
------- | ||
bool | ||
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. same comment 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 |
||
|
||
Examples | ||
-------- | ||
>>> s = pd.Series([2, 1, 3, 4], index=['Falcon', 'Falcon', 'Parrot', 'Parrot']) | ||
>>> s.groupby(level=0).is_monotonic_increasing | ||
Falcon False | ||
Parrot True | ||
dtype: bool | ||
""" | ||
return self.apply(lambda ser: ser.is_monotonic_increasing) | ||
|
||
@property | ||
@doc(Series.is_monotonic_decreasing.__doc__) | ||
def is_monotonic_decreasing(self) -> Series: | ||
# GH13 | ||
""" | ||
Return boolean if values in the group are monotonically decreasing. | ||
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. so sorry, I missed this the first time round it doesn't return a boolean, but a Series of booleans 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. My fault 🫣 |
||
|
||
Returns | ||
------- | ||
bool | ||
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. Series 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. Changed |
||
|
||
Examples | ||
-------- | ||
>>> s = pd.Series([2, 1, 3, 4], index=['Falcon', 'Falcon', 'Parrot', 'Parrot']) | ||
>>> s.groupby(level=0).is_monotonic_decreasing | ||
Falcon True | ||
Parrot False | ||
dtype: bool | ||
""" | ||
return self.apply(lambda ser: ser.is_monotonic_decreasing) | ||
|
||
@doc(Series.hist.__doc__) | ||
|
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.
this one also returns
bool
;) rest looks good though!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.
I should have seen it :) .. thanks