Skip to content

Commit 1effc38

Browse files
authored
Time Series: More compatibility with pandas 2.0 (#496)
> `groupby.mean()` has `numeric_only=` argument whose default value was > `True` in the past but since pandas 2.0, its default value is `False`. > > An implication is that string columns are not dropped when a > statistical method such as `mean` or `std` is called on the `groupby` > object (as was done in the past). To solve the issue, pass > `numeric_only=True`. > > -- https://stackoverflow.com/a/76597931
1 parent 3ed51f3 commit 1effc38

File tree

3 files changed

+2
-5
lines changed

3 files changed

+2
-5
lines changed

topic/timeseries/exploratory_data_analysis.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@
560560
"df_berlin.index = pd.to_datetime(df_berlin.index)\n",
561561
"\n",
562562
"# Now aggregate to daily averages\n",
563-
"df_berlin_daily_avg = df_berlin.resample('D').mean()\n",
563+
"df_berlin_daily_avg = df_berlin.resample('D').mean(numeric_only=True)\n",
564564
"\n",
565565
"df_berlin_daily_avg.reset_index(inplace=True)\n",
566566
"\n",

topic/timeseries/test.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,5 @@ def test_notebook(notebook):
1919
raise pytest.skip(f"Kaggle dataset can not be tested "
2020
f"without authentication: {notebook.name}")
2121

22-
if notebook.name in ["exploratory_data_analysis.ipynb", "time-series-decomposition.ipynb"]:
23-
raise pytest.skip(f"Notebook is not compatible with pandas 2.x: {notebook.name}")
24-
2522
with testbook(notebook) as tb:
2623
tb.execute()

topic/timeseries/time-series-decomposition.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@
566566
"df_berlin.index = pd.to_datetime(df_berlin.index)\n",
567567
"\n",
568568
"# Now aggregate to daily averages\n",
569-
"df_berlin_daily_avg = df_berlin.resample('D').mean()\n",
569+
"df_berlin_daily_avg = df_berlin.resample('D').mean(numeric_only=True)\n",
570570
"\n",
571571
"df_berlin_daily_avg.reset_index(inplace=True)\n",
572572
"\n",

0 commit comments

Comments
 (0)