-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: update the pandas.Series/DataFrame.interpolate docstring #20270
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 1 commit
b39289f
0f5f666
5358af9
6cee318
ba8cfd2
272d5e2
d64f5f3
0734c3b
1eab0a8
3ca95ec
b123846
3af4306
3f00e93
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 |
---|---|---|
|
@@ -6096,15 +6096,15 @@ def replace(self, to_replace=None, value=None, inplace=False, limit=None, | |
* 'pad': Fill in NaNs using existing values. | ||
* 'nearest', 'zero', 'slinear', 'quadratic', 'cubic', 'spline', | ||
'barycentric', 'polynomial': Passed to | ||
``scipy.interpolate.interp1d``. Both 'polynomial' and 'spline' | ||
`scipy.interpolate.interp1d`. Both 'polynomial' and 'spline' | ||
require that you also specify an `order` (int), | ||
e.g. ``df.interpolate(method='polynomial', order=4)``. | ||
These use the numerical values of the index. | ||
* 'krogh', 'piecewise_polynomial', 'spline', 'pchip', 'akima': | ||
Wrappers around the SciPy interpolation methods of similar | ||
names. See `Notes`. | ||
* 'from_derivatives': Refers to | ||
``scipy.interpolate.BPoly.from_derivatives`` which | ||
`scipy.interpolate.BPoly.from_derivatives` which | ||
replaces 'piecewise_polynomial' interpolation method in | ||
scipy 0.18. | ||
|
||
|
@@ -6129,7 +6129,7 @@ def replace(self, to_replace=None, value=None, inplace=False, limit=None, | |
If limit is specified, consecutive NaNs will be filled with this | ||
restriction. | ||
|
||
* None: No fill restriction. | ||
* ``None``: No fill restriction. | ||
* 'inside': Only fill NaNs surrounded by valid values | ||
(interpolate). | ||
* 'outside': Only fill NaNs outside valid values (extrapolate). | ||
|
@@ -6145,7 +6145,7 @@ def replace(self, to_replace=None, value=None, inplace=False, limit=None, | |
------- | ||
Series or DataFrame | ||
Returns the same object type as the caller, interpolated at | ||
some or all `NaN` values | ||
some or all ``NaN`` values | ||
|
||
See Also | ||
-------- | ||
|
@@ -6174,7 +6174,7 @@ def replace(self, to_replace=None, value=None, inplace=False, limit=None, | |
|
||
Examples | ||
-------- | ||
Filling in `NaN` in a :class:`~pandas.Series` via linear | ||
Filling in ``NaN`` in a :class:`~pandas.Series` via linear | ||
interpolation. | ||
|
||
>>> s = pd.Series([0, 1, np.nan, 3]) | ||
|
@@ -6191,8 +6191,8 @@ def replace(self, to_replace=None, value=None, inplace=False, limit=None, | |
3 3.0 | ||
dtype: float64 | ||
|
||
Filling in `NaN` in a Series by padding, but filling at most two | ||
consecutive `NaN` at a time. | ||
Filling in ``NaN`` in a Series by padding, but filling at most two | ||
consecutive ``NaN`` at a time. | ||
|
||
>>> s = pd.Series([np.nan, "single_one", np.nan, | ||
... "fill_two_more", np.nan, np.nan, np.nan, | ||
|
@@ -6220,9 +6220,9 @@ def replace(self, to_replace=None, value=None, inplace=False, limit=None, | |
8 4.71 | ||
dtype: object | ||
|
||
Filling in `NaN` in a Series via polynomial interpolation or splines: | ||
Both `polynomial` and `spline` methods require that you also specify | ||
an `order` (int). | ||
Filling in ``NaN`` in a Series via polynomial interpolation or splines: | ||
Both 'polynomial' and 'spline' methods require that you also specify | ||
an ``order`` (int). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Parameters should be single backticks - double is only for literals and code samples I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My understanding is that double backticks is for code, including parts like a single variable For an argument, I'd consider it more code, that something you can link to. That's why I added double backticks. But it's very subtle, I'd be happy with any option (no quoting, single backticks, double backticks and quotes). Does this make sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep thanks. I think I've seen other instances where parameters are in single backticks but this is nuanced enough that it shouldn't hold up the PR - can be part of a larger conversation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a bullet point to #20298 to decide a standard for these cases. I think at the moment there is not much consistency. |
||
|
||
>>> s = pd.Series([0, 2, np.nan, 8]) | ||
>>> s.interpolate(method='polynomial', order=2) | ||
|
@@ -6235,9 +6235,9 @@ def replace(self, to_replace=None, value=None, inplace=False, limit=None, | |
Fill the DataFrame forward (that is, going down) along each column | ||
using linear interpolation. | ||
|
||
Note how the last entry in column `a` is interpolated differently, | ||
Note how the last entry in column 'a' is interpolated differently, | ||
because there is no entry after it to use for interpolation. | ||
Note how the first entry in column `b` remains `NaN`, because there | ||
Note how the first entry in column 'b' remains ``NaN``, because there | ||
is no entry befofe it to use for interpolation. | ||
|
||
>>> df = pd.DataFrame([(0.0, np.nan, -1.0, 1.0), | ||
|
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.
Would be good to add an example for 'outside'