Skip to content
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

Merged
merged 6 commits into from
Sep 10, 2024

Conversation

ammar-qazi
Copy link
Contributor

Fixed:

pandas.api.extensions.ExtensionArray.interpolate PR01,SA01

@ammar-qazi ammar-qazi changed the title Extensionarray interpolate DOC: Add docstring for Extensionarray interpolate Sep 8, 2024
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.
Copy link
Member

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.

Copy link
Contributor Author

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.

Comment on lines 1035 to 1038
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'.
Copy link
Member

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

Copy link
Contributor Author

@ammar-qazi ammar-qazi Sep 9, 2024

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)


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]))
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reverted the change.

@mroeschke mroeschke added the Docs label Sep 9, 2024
@ammar-qazi ammar-qazi force-pushed the extensionarray_interpolate branch 2 times, most recently from 1e7c5d6 to 5957fc0 Compare September 9, 2024 21:19
@ammar-qazi ammar-qazi marked this pull request as draft September 9, 2024 21:23
@ammar-qazi ammar-qazi marked this pull request as ready for review September 9, 2024 22:06
@mroeschke mroeschke added this to the 3.0 milestone Sep 10, 2024
@mroeschke mroeschke merged commit 16b7288 into pandas-dev:main Sep 10, 2024
47 checks passed
@mroeschke
Copy link
Member

Thanks @ammar-qazi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants