Skip to content

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

Merged
merged 1 commit into from
Jul 6, 2018
Merged

Fixes example code in docstring of pandas.DataFrame.query #21731

merged 1 commit into from
Jul 6, 2018

Conversation

alphaCTzo7G
Copy link
Contributor

@alphaCTzo7G alphaCTzo7G commented Jul 4, 2018

@@ -2841,7 +2841,7 @@ def query(self, expr, inplace=False, **kwargs):
--------
>>> from numpy.random import randn
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

@alphaCTzo7G alphaCTzo7G Jul 5, 2018

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
Copy link

codecov bot commented Jul 4, 2018

Codecov Report

Merging #21731 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #21731   +/-   ##
=======================================
  Coverage   91.92%   91.92%           
=======================================
  Files         158      158           
  Lines       49705    49705           
=======================================
  Hits        45693    45693           
  Misses       4012     4012
Flag Coverage Δ
#multiple 90.3% <ø> (ø) ⬆️
#single 41.99% <ø> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/frame.py 97.19% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1070976...2b5a8ea. Read the comment docs.

@gfyoung gfyoung added the Docs label Jul 5, 2018
Copy link
Member

@gfyoung gfyoung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

cc @jreback

@jreback jreback added this to the 0.24.0 milestone Jul 6, 2018
@jreback jreback merged commit 04caa56 into pandas-dev:master Jul 6, 2018
@jreback
Copy link
Contributor

jreback commented Jul 6, 2018

thanks @alphaCTzo7G

@alphaCTzo7G alphaCTzo7G deleted the fix_typo_query branch July 7, 2018 23:51
Sup3rGeo pushed a commit to Sup3rGeo/pandas that referenced this pull request Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error in docstring for pandas/core/frame.py
3 participants