-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
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
Changes from 3 commits
bab3a2b
cd3ec62
1ee2751
2cbf5dd
92c1d2f
5bcee6d
2729193
4851b91
be1a774
7072e4a
88e6e37
38c5c94
4518791
9d58d4e
363e8c0
4d59844
6bf4977
2a838f2
7df1f79
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3331,12 +3331,18 @@ def select(self, crit, axis=0): | |||||
|
|
||||||
| def reindex_like(self, other, method=None, copy=True, limit=None, | ||||||
| tolerance=None): | ||||||
| """Return an object with matching indices to myself. | ||||||
| """ | ||||||
| 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. | ||||||
|
|
||||||
| Parameters | ||||||
| ---------- | ||||||
| other : Object | ||||||
|
||||||
| method : string or None | ||||||
| method : {None, 'backfill'/'bfill', 'pad'/'ffill', 'nearest'} | ||||||
math-and-data marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| copy : boolean, default True | ||||||
|
||||||
| limit : int, default None | ||||||
| Maximum number of consecutive labels to fill for inexact matches. | ||||||
|
|
@@ -3348,12 +3354,43 @@ def reindex_like(self, other, method=None, copy=True, limit=None, | |||||
|
|
||||||
| Notes | ||||||
| ----- | ||||||
| Like calling s.reindex(index=other.index, columns=other.columns, | ||||||
| method=...) | ||||||
| Like calling `.reindex(index=other.index, columns=other.columns, | ||||||
math-and-data marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| method=...)` | ||||||
|
|
||||||
| Returns | ||||||
| ------- | ||||||
| reindexed : same as input | ||||||
| Object | ||||||
| same object type as input, but with changed indices on each axis | ||||||
|
||||||
|
|
||||||
| See Also | ||||||
| -------- | ||||||
| DataFrame.set_index : set row labels | ||||||
| DataFrame.reset_index : remove row labels or move them to new columns | ||||||
| DataFrame.reindex : change to new indices or expand indices | ||||||
|
|
||||||
| Examples | ||||||
| -------- | ||||||
| >>> df_weather_station_1 = pd.DataFrame([[24.3, 75.7, 'high'], | ||||||
|
||||||
| ... [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')) | ||||||
|
|
||||||
| >>> 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'])) | ||||||
datapythonista marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| >>> df_weather_station_2.reindex_like(df_weather_station_1) | ||||||
| temp_celsius temp_fahrenheit windspeed | ||||||
| 2014-02-12 28.0 NaN low | ||||||
| 2014-02-13 30.0 NaN low | ||||||
| 2014-02-14 NaN NaN NaN | ||||||
| 2014-02-15 35.1 NaN medium | ||||||
| """ | ||||||
| d = other._construct_axes_dict(axes=self._AXIS_ORDERS, method=method, | ||||||
| copy=copy, limit=limit, | ||||||
|
|
@@ -3769,6 +3806,12 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False, | |||||
|
|
||||||
| .. versionadded:: 0.21.0 (list-like tolerance) | ||||||
|
|
||||||
| See Also | ||||||
| -------- | ||||||
| DataFrame.set_index : set row labels | ||||||
| DataFrame.reset_index : remove row labels or move them to new columns | ||||||
| DataFrame.reindex_like : change to same indices as other DataFrame | ||||||
|
||||||
|
|
||||||
| Examples | ||||||
| -------- | ||||||
|
|
||||||
|
|
@@ -3994,11 +4037,10 @@ def _needs_reindex_multi(self, axes, method, level): | |||||
| def _reindex_multi(self, axes, copy, fill_value): | ||||||
| return NotImplemented | ||||||
|
|
||||||
| _shared_docs[ | ||||||
| 'reindex_axis'] = ("""Conform input object to new index with 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 | ||||||
| _shared_docs['reindex_axis'] = ("""Conform input object to new index | ||||||
math-and-data marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| with 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. | ||||||
|
|
||||||
| Parameters | ||||||
| ---------- | ||||||
|
|
@@ -4035,17 +4077,20 @@ def _reindex_multi(self, axes, copy, fill_value): | |||||
|
|
||||||
| .. versionadded:: 0.21.0 (list-like tolerance) | ||||||
|
|
||||||
| Examples | ||||||
| -------- | ||||||
| >>> df.reindex_axis(['A', 'B', 'C'], axis=1) | ||||||
|
|
||||||
| See Also | ||||||
| -------- | ||||||
| reindex, reindex_like | ||||||
| DataFrame.set_index : set row labels | ||||||
| DataFrame.reset_index : remove row labels or move them to new columns | ||||||
| DataFrame.reindex : change to new indices or expand indices | ||||||
| DataFrame.reindex_like : change to same indices as other DataFrame | ||||||
|
||||||
|
|
||||||
| Returns | ||||||
| ------- | ||||||
| reindexed : %(klass)s | ||||||
|
||||||
| reindexed : %(klass)s | |
| %(klass)s |
And add a short description of what is being returned in the next line.
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.
Can you capitalize the first letter of each description, and add a period at the end please