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

Ensure compatibility with pandas CoW #842

Merged
merged 7 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE_NOTES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Next release
All changes
-----------

- Ensure compatibility with pandas upcoming 3.0 Copy-on-Write behaviour (:pull:`842`).
- Update tutorial Westeros multinode to include code-based hints for in-depth questions (:pull:`798`).
- :func:`.make_df` can now create partly-filled :class:`DataFrames <pandas.DataFrame>` for indexed sets; not only parameters (:pull:`784`).
- New function :func:`.util.copy_model` that exposes the behaviour of the :program:`message-ix copy-model` CLI command to other Python code (:pull:`784`).
Expand Down
7 changes: 6 additions & 1 deletion message_ix/macro.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ def extrapolate(
The index does *not* have a ``year`` dimension; the data are implicitly for
`ym1`.
"""
from sys import version_info

from scipy.optimize import curve_fit

def f(x, b, m):
Expand All @@ -286,8 +288,11 @@ def fitted_intercept(df: pd.DataFrame) -> float:

# Apply fitted_intercept to grouped data
groupby_cols = set(model_data.columns) - {"year", "value"}
apply_kwargs = {"include_groups": False} if version_info.minor > 8 else {}
result = (
model_data.groupby(list(groupby_cols)).apply(fitted_intercept).rename("value")
model_data.groupby(list(groupby_cols))
.apply(fitted_intercept, **apply_kwargs)
.rename("value")
)

# Convert "commodity" and "level" to "sector"
Expand Down
Loading
Loading