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

Inplace translation of pandas.Series after PDEP-6 #170

Open
rsundqvist opened this issue Nov 4, 2023 · 0 comments
Open

Inplace translation of pandas.Series after PDEP-6 #170

rsundqvist opened this issue Nov 4, 2023 · 0 comments

Comments

@rsundqvist
Copy link
Owner

rsundqvist commented Nov 4, 2023

Description

After PDEP-6, assigning values incompatible with the current dtype will require explicit an type conversion.

This will break inplace translation, since Series.astype returns a new object. It (should?) keep working for DataFrame, as in that case we simply replace the entire column.

Possible solution

Detect if pandas.Series is compatible with strings. If not, raise NotInplaceTranslatableError if inplace=True.

def series_inplace_translatable() -> bool:
    try:
        pd.Series(dtype=int)[:] = ""
    except ExceptionType:
        raise NotInplaceTranslatableError

The exact exception type that will be raised is not known yet.

@rsundqvist rsundqvist added this to the Release 1.0.0 (stable) milestone Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant