-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Added example to Dataframe.get docs #43233
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
Added example to Dataframe.get docs #43233
Conversation
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.
Thanks for your PR - could you make the example one such that it shows the use of the default
argument?
you mean this one right? @MarcoGorelli
|
I think, something like this ( In [9]: df.get(["temp_celsius","windspeed","temp_Kelvin"], default = "Some column missing")
Out[9]: 'Some column missing' |
have you run the validate_docstrings script? https://pandas.pydata.org/pandas-docs/stable/development/contributing_documentation.html#updating-a-pandas-docstring |
yes. Tested the |
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.
couple of comments, other than that looks good
pandas/core/generic.py
Outdated
>>> df1 = df.get(["temp_celsius","windspeed"]) | ||
|
||
>>> df1 | ||
temp_celsius windspeed | ||
2014-02-12 24.3 high | ||
2014-02-13 31.0 high | ||
2014-02-14 22.0 medium | ||
2014-02-15 35.0 medium |
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.
no need to assign to a new variable, let's just print the first one
>>> df1 = df.get(["temp_celsius","windspeed"]) | |
>>> df1 | |
temp_celsius windspeed | |
2014-02-12 24.3 high | |
2014-02-13 31.0 high | |
2014-02-14 22.0 medium | |
2014-02-15 35.0 medium | |
>>> df.get(["temp_celsius", "windspeed"]) | |
temp_celsius windspeed | |
2014-02-12 24.3 high | |
2014-02-13 31.0 high | |
2014-02-14 22.0 medium | |
2014-02-15 35.0 medium |
pandas/core/generic.py
Outdated
>>> df2 = df.get(["temp_celsius","temp_kelvin"], default = "default_value") | ||
|
||
>>> df2 | ||
'default_value' |
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.
likewise, and dedent the result
>>> df2 = df.get(["temp_celsius","temp_kelvin"], default = "default_value") | |
>>> df2 | |
'default_value' | |
>>> df.get(["temp_celsius", "temp_kelvin"], default = "default_value") | |
'default_value' |
These errors from
|
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.
@MarcoGorelli How did you remove those errors? I have tried using autopep8 in vscode, It did nothing for me. Can u please explain a bit? |
* added example to Dataframe.get * added example for default param in dataframe.get doc * made suggested changes in dataframe.get example * more changes * fixup Co-authored-by: Marco Gorelli <[email protected]>
@MarcoGorelli