-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: Add docstring for Extensionarray interpolate #59749
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
DOC: Add docstring for Extensionarray interpolate #59749
Conversation
pandas/core/arrays/base.py
Outdated
of similar names. See Notes. | ||
* 'from_derivatives': Refers to scipy.interpolate.BPoly.from_derivatives. | ||
axis : int | ||
Axis to interpolate along. For 1D NumpyExtensionArray, use 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.
This docstring should not mention NumpyExtensionArray
at all.
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.
I've resolved this issue. Plus, I've also included example of FloatingArray
to make the documentation more helpful for users.
pandas/core/arrays/base.py
Outdated
Raises ValueError if limit_direction is 'forward' or 'both' and method | ||
is 'backfill' or 'bfill'. | ||
Raises ValueError if limit_direction is 'backward' or 'both' and method | ||
is 'pad' or 'ffill'. |
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.
Could you put this in it's own Raises
section? Please review the numpydoc documentation for where a Raises
section should be placed
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.
I borrowed these insights from pandas.DataFrame.interpolate`. However, it appears that there's an issue with that documentation as well.
There's no method of ffill, bfill, or backfill. Besides that, the function fails in all cases if you use "pad."
For instance, even this raises a ValueError:
import pandas as pd
import numpy as np
# Create a sample DataFrame with NaN values
df = pd.DataFrame({
'A': [1, 2, np.nan, np.nan, 5, 6]
})
print("Original DataFrame:")
print(df)
# Use interpolate with pad method
df_interpolated = df.interpolate(method='pad')
print("\nInterpolated DataFrame:")
print(df_interpolated)
pandas/core/arrays/base.py
Outdated
|
||
Examples | ||
-------- | ||
>>> arr = pd.arrays.NumpyExtensionArray(np.array([0, 1, np.nan, 3])) | ||
>>> arr = pd.arrays.NumpyExtensionArray(np.array([0, np.nan, 2, np.nan, 4])) |
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.
Why did this example change?
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.
I reverted the change.
1e7c5d6
to
5957fc0
Compare
5957fc0
to
b4bf7c9
Compare
b4bf7c9
to
23d67f6
Compare
Thanks @ammar-qazi |
Fixed: