10000 DOC: update the DataFrame.reindex_like docstring by math-and-data · Pull Request #22775 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

DOC: update the DataFrame.reindex_like docstring #22775

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 19 commits into from
Nov 26, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
DOC: Improve the docstring of DataFrame.reindex_like()
  • Loading branch information
math-and-data committed Sep 19, 2018
commit cd3ec6273b9030a53e83743af8f1fcb09894351c
2 changes: 1 addition & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3986,7 +3986,7 @@ def reset_index(self, level=None, drop=False, inplace=False, col_level=0,
Returns
-------
resetted : DataFrame

See Also
--------
DataFrame.set_index : opposite of reset_index
Expand Down
25 changes: 13 additions & 12 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3333,11 +3333,11 @@ def reindex_like(self, other, method=None, copy=True, limit=None,
tolerance=None):
"""
Return an object with matching indices as other object.
Conform the object to the same index on all axes. Optional filling logic,
placing NA/NaN in locations having no value in the previous index.
A new object is produced unless the new index is equivalent to the
current one and copy=False.

Conform the object to the same index on all axes. Optional
filling logic, placing NA/NaN in locations having no value
Copy link
Member

Choose a reason for hiding this comment

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

Just say NaN

in the previous index. A new object is produced unless the
new index is equivalent to the current one and copy=False.

Parameters
----------
Expand All @@ -3360,7 +3360,7 @@ def reindex_like(self, other, method=None, copy=True, limit=None,
Returns
-------
Object
same object type as input object, but with changed indices on each axis
same object type as input, but with changed indices on each axis
Copy link
Member

Choose a reason for hiding this comment

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

You can leave out the "Object" line, and directly put the explanation on that line.

And can you use Capital first character and end point punctuation?


See Also
--------
Expand All @@ -3369,19 +3369,21 @@ def reindex_like(self, other, method=None, copy=True, limit=None,
DataFrame.reindex : change to new indices or expand indices

Examples
--------
--------
>>> df_weather_station_1 = pd.DataFrame([[24.3, 75.7, 'high'],
Copy link
Member

Choose a reason for hiding this comment

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

I don't think the _weather_station bit adds any value; would be OK to just use df1, df2, etc...

... [31, 87.8, 'high'],
... [22, 71.6, 'medium'],
... [35, 95, 'medium']],
... columns=['temp_celsius', 'temp_fahrenheit', 'windspeed'],
... index=pd.date_range(start='2014-02-12', end='2014-02-15', freq='D'))
... index=pd.date_range(start='2014-02-12',
... end='2014-02-15', freq='D'))

>>> df_weather_station_2 = pd.DataFrame([[28, 'low'],
>>> df_weather_station_2 = pd.DataFrame([[28, 'low'],
... [30, 'low'],
... [35.1, 'medium']],
... columns=['temp_celsius', 'windspeed'],
... index=pd.DatetimeIndex(['2014-02-12', '2014-02-13', '2014-02-15']))
... columns=['temp_celsius', 'windspeed'],
... index=pd.DatetimeIndex(['2014-02-12', '2014-02-13',
... '2014-02-15']))

>>> df_weather_station_2.reindex_like(df_weather_station_1)
temp_celsius temp_fahrenheit windspeed
Expand Down Expand Up @@ -4088,7 +4090,6 @@ def _reindex_multi(self, axes, copy, fill_value):

Examples
--------

>>> df.reindex_axis(['A', 'B', 'C'], axis=1)
""")

Expand Down
0