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

FutureWarning when downcasting with pandas replace() function in AIT tutorial #99

Open
agmoore4 opened this issue Sep 11, 2024 · 0 comments

Comments

@agmoore4
Copy link

See: pandas-dev/pandas#57734

In tutorials/tutorial_AIT_timeseries.ipynb, the dc capacity for each site is added to filtered_prod_data using replace() to map between the site id and the site capacity. However, this implicitly downcasts the column from object dtype to int64. This behavior is deprecated and will be removed in future versions of pandas.

The recommended approach based on the warning is to use pd.option_context(future.no_silent_downcasting, True) and then cast the column's dtype manually. However, in later releases of pandas once this behavior becomes standard, this context manager will itself become deprecated according to: https://pandas.pydata.org/docs/reference/api/pandas.describe_option.html

A better approach may be doing the replacement more explicitly via a masking approach, which is still simple and readable and avoids further reworks of this code with updates to pandas.

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