-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Fixes example code in docstring of pandas.DataFrame.query #21731
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
Conversation
pandas/core/frame.py
Outdated
@@ -2841,7 +2841,7 @@ def query(self, expr, inplace=False, **kwargs): | |||
-------- | |||
>>> from numpy.random import randn |
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.
ahh these are the old forms, can you rather amend to
import numpy as np
import pandas as pd
then change the randn call
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.
@jreback Ok.. I changed it as follows..
>>> import numpy as np
>>> import pandas as pd
>>> df = pd.DataFrame(np.random.randn(10, 2), columns=list('ab'))
>>> df.query('a > b')
>>> df[df.a > df.b] # same result as the previous expression
I force pushed it to the same branch..
https://github.com/alphaCTzo7G/pandas/tree/fix_typo_query
I noticed there are some other docstrings with from pandas
or from numpy
..
./pandas/plotting/_converter.py|134 col 17| ">>> from pandas.plotting import register_matplotlib_converters"
./pandas/plotting/_misc.py|501 col 5| >>> from pandas import read_csv
./pandas/plotting/_misc.py|502 col 5| >>> from pandas.tools.plotting import parallel_coordinates
./pandas/util/testing.py|602 col 5| >>> from pandas.util.testing import capture_stdout
./pandas/util/testing.py|650 col 5| >>> from pandas.util.testing import capture_stderr
./pandas/util/testing.py|2213 col 7| >>> from pandas.util.testing import network
./pandas/util/testing.py|2214 col 7| >>> from pandas.io.common import urlopen
./pandas/tseries/holiday.py|145 col 9| >>> from pandas.tseries.holiday import Holiday, nearest_workday
./pandas/tseries/holiday.py|146 col 9| >>> from pandas import DateOffset
pandas/core/sparse/series.py|739 col 9| >>> from numpy import nan
pandas/core/algorithms.py|1519 col 5| >>> from pandas.api.extensions import take
pandas/core/dtypes/concat.py|285 col 5| >>> from pandas.api.types import union_categoricals
./pandas/io/pytables.py|457 col 5| >>> from pandas import DataFrame
./pandas/io/pytables.py|458 col 5| >>> from numpy.random import randn
./pandas/io/json/normalize.py|138 col 5| >>> from pandas.io.json import json_normalize
./pandas/io/stata.py|2713 col 5| >>> from pandas.io.stata import StataWriter117
Do these need to be adjusted as well?
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.
Probably, but don't fix them here. Would do in a separate PR.
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.
Ok.. I will create 1 PR to fix the rest of them.
Codecov Report
@@ Coverage Diff @@
## master #21731 +/- ##
=======================================
Coverage 91.92% 91.92%
=======================================
Files 158 158
Lines 49705 49705
=======================================
Hits 45693 45693
Misses 4012 4012
Continue to review full report at Codecov.
|
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.
LGTM!
cc @jreback
thanks @alphaCTzo7G |
git diff upstream/master -u -- "*.py" | flake8 --diff