Skip to content

Commit

Permalink
fix: gapminder to be compatible with Pandas 2.0.3 (deephaven#586)
Browse files Browse the repository at this point in the history
The current version of the ticking Gapminder dataset uses a feature only
available in Pandas 2.1.4. Deephaven will work with Python 3.8, but
Pandas 2.1 has a minimum Python version of 3.9. So, the feature that
Gapminder depends on is not guaranteed to be available to DH. This PR
removes that feature and replicates the functionality with an older
feature.
  • Loading branch information
alexpeters1208 authored Jun 27, 2024
1 parent bd8cca9 commit fae2f75
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -654,9 +654,10 @@ def create_empty(val: Any, reps: int) -> list[Any]:
gapminder_no_2007.loc[:, ["year"]] = gapminder_no_2007["year"].apply(
lambda x: create_years(x, 5)
)
gapminder_no_2007.loc[:, ["lifeExp", "pop", "gdpPercap"]] = gapminder_no_2007[
["lifeExp", "pop", "gdpPercap"]
].map(lambda x: create_empty(x, 5))
for col in ["lifeExp", "pop", "gdpPercap"]:
gapminder_no_2007.loc[:, [col]] = gapminder_no_2007[col].apply(
lambda x: create_empty(x, 5)
)
gapminder_no_2007 = gapminder_no_2007.explode(
column=["year", "lifeExp", "pop", "gdpPercap"]
)
Expand All @@ -672,9 +673,10 @@ def create_empty(val: Any, reps: int) -> list[Any]:
)

# expand pre-2007 dataset into consecutive months
gapminder_no_2007.loc[:, ["lifeExp", "pop", "gdpPercap"]] = gapminder_no_2007[
["lifeExp", "pop", "gdpPercap"]
].map(lambda x: create_empty(x, 12))
for col in ["lifeExp", "pop", "gdpPercap"]:
gapminder_no_2007.loc[:, [col]] = gapminder_no_2007[col].apply(
lambda x: create_empty(x, 12)
)
gapminder_no_2007 = gapminder_no_2007.explode(
column=["month", "lifeExp", "pop", "gdpPercap"]
)
Expand Down

0 comments on commit fae2f75

Please sign in to comment.