Skip to content

DOC: standardizing docstrings to use pd.DataFrame #18788

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 2 commits into from
Dec 16, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -2304,7 +2304,7 @@ def query(self, expr, inplace=False, **kwargs):
--------
>>> from numpy.random import randn
>>> from pandas import DataFrame
>>> df = DataFrame(randn(10, 2), columns=list('ab'))
>>> df = pd.DataFrame(randn(10, 2), columns=list('ab'))
>>> df.query('a > b')
>>> df[df.a > df.b] # same result as the previous expression
"""
Expand Down Expand Up @@ -2368,7 +2368,7 @@ def eval(self, expr, inplace=False, **kwargs):
--------
>>> from numpy.random import randn
>>> from pandas import DataFrame
>>> df = DataFrame(randn(10, 2), columns=list('ab'))
>>> df = pd.DataFrame(randn(10, 2), columns=list('ab'))
>>> df.eval('a + b')
>>> df.eval('c = a + b')
"""
Expand Down Expand Up @@ -2664,7 +2664,7 @@ def assign(self, **kwargs):

Examples
--------
>>> df = DataFrame({'A': range(1, 11), 'B': np.random.randn(10)})
>>> df = pd.DataFrame({'A': range(1, 11), 'B': np.random.randn(10)})

Where the value is a callable, evaluated on `df`:

Expand Down Expand Up @@ -3780,7 +3780,7 @@ def nlargest(self, n, columns, keep='first'):

Examples
--------
>>> df = DataFrame({'a': [1, 10, 8, 11, -1],
>>> df = pd.DataFrame({'a': [1, 10, 8, 11, -1],
... 'b': list('abdce'),
Copy link
Member

@gfyoung gfyoung Dec 15, 2017

Choose a reason for hiding this comment

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

Although this won't fail, but style-wise, notice how the "a", "b", and "c" rows are aligned and start at that same location on their respective lines. Let's keep it that way (i.e. adjust the "b" and "c" rows).

Copy link
Member

Choose a reason for hiding this comment

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

Follow this comment for one of your other fixes down below (the "column=['a', 'b']").

... 'c': [1.0, 2.0, np.nan, 3.0, 4.0]})
>>> df.nlargest(3, 'a')
Expand Down Expand Up @@ -3815,7 +3815,7 @@ def nsmallest(self, n, columns, keep='first'):

Examples
--------
>>> df = DataFrame({'a': [1, 10, 8, 11, -1],
>>> df = pd.DataFrame({'a': [1, 10, 8, 11, -1],
... 'b': list('abdce'),
... 'c': [1.0, 2.0, np.nan, 3.0, 4.0]})
>>> df.nsmallest(3, 'a')
Expand Down Expand Up @@ -5818,7 +5818,7 @@ def quantile(self, q=0.5, axis=0, numeric_only=True,
Examples
--------

>>> df = DataFrame(np.array([[1, 1], [2, 10], [3, 100], [4, 100]]),
>>> df = pd.DataFrame(np.array([[1, 1], [2, 10], [3, 100], [4, 100]]),
columns=['a', 'b'])
>>> df.quantile(.1)
a 1.3
Expand Down Expand Up @@ -5941,7 +5941,7 @@ def isin(self, values):
--------
When ``values`` is a list:

>>> df = DataFrame({'A': [1, 2, 3], 'B': ['a', 'b', 'f']})
>>> df = pd.DataFrame({'A': [1, 2, 3], 'B': ['a', 'b', 'f']})
>>> df.isin([1, 3, 12, 'a'])
A B
0 True True
Expand All @@ -5950,7 +5950,7 @@ def isin(self, values):

When ``values`` is a dict:

>>> df = DataFrame({'A': [1, 2, 3], 'B': [1, 4, 7]})
>>> df = pd.DataFrame({'A': [1, 2, 3], 'B': [1, 4, 7]})
>>> df.isin({'A': [1, 3], 'B': [4, 7, 12]})
A B
0 True False # Note that B didn't match the 1 here.
Expand All @@ -5959,7 +5959,7 @@ def isin(self, values):

When ``values`` is a Series or DataFrame:

>>> df = DataFrame({'A': [1, 2, 3], 'B': ['a', 'b', 'f']})
>>> df = pd.DataFrame({'A': [1, 2, 3], 'B': ['a', 'b', 'f']})
>>> other = DataFrame({'A': [1, 3, 3, 2], 'B': ['e', 'f', 'f', 'e']})
>>> df.isin(other)
A B
Expand Down