Skip to content

Commit b66cc8b

Browse files
committed
pandas 3 fixes
1 parent c376441 commit b66cc8b

4 files changed

Lines changed: 36 additions & 9 deletions

File tree

notebooks/part1_flopy/03_Loading_and_visualizing_models.ipynb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,13 +1100,24 @@
11001100
"fig, ax = plt.subplots(figsize=(10, 5))\n",
11011101
"in_cols = ['STO-SS_IN', 'STO-SY_IN', 'WEL_IN', 'RCHA_IN', 'CHD_IN', 'SFR_IN', 'LAK_IN']\n",
11021102
"out_cols = [c.replace('_IN', '_OUT') for c in in_cols]\n",
1103+
"# as of pandas 3.0.1, \n",
1104+
"# the datatime index of the flux dataframe produced by Flopy produces an error with .plot.bar();\n",
1105+
"# switch the index to a categorical (date string) index instead\n",
1106+
"flux.index = flux.index.strftime('%Y-%m-%d')\n",
11031107
"flux[in_cols].plot.bar(stacked=True, ax=ax)\n",
11041108
"(-flux[out_cols]).plot.bar(stacked=True, ax=ax)\n",
11051109
"ax.legend(loc='lower left', bbox_to_anchor=(1, 0))\n",
11061110
"ax.axhline(0, lw=0.5, c='k')\n",
11071111
"ax.set_ylabel('Simulated Flux, in $m^3/d$')"
11081112
]
11091113
},
1114+
{
1115+
"cell_type": "code",
1116+
"execution_count": null,
1117+
"metadata": {},
1118+
"outputs": [],
1119+
"source": []
1120+
},
11101121
{
11111122
"cell_type": "markdown",
11121123
"metadata": {},
@@ -1142,7 +1153,7 @@
11421153
"name": "python",
11431154
"nbconvert_exporter": "python",
11441155
"pygments_lexer": "ipython3",
1145-
"version": "3.12.11"
1156+
"version": "3.14.3"
11461157
}
11471158
},
11481159
"nbformat": 4,

notebooks/part1_flopy/07-stream_capture_voronoi.ipynb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,8 +661,8 @@
661661
"for gage_num in range(2):\n",
662662
" for lay_num in range(3):\n",
663663
" cax = ax[ax_num]\n",
664-
" data = drf.loc[lay_num][f'Gage{gage_num+1}'].values\n",
665-
" data[data<0] =0\n",
664+
" data = drf.loc[lay_num][f'Gage{gage_num+1}'].values.copy()\n",
665+
" data[data < 0] = 0\n",
666666
" mm = fp.plot.PlotMapView(model= base_m, ax=cax)\n",
667667
" mm.plot_bc('SFR', plotAll=True, color='blue')\n",
668668
" mm.plot_bc('WEL', plotAll=True)\n",
@@ -696,9 +696,21 @@
696696
],
697697
"metadata": {
698698
"kernelspec": {
699-
"display_name": "Python 3 (ipykernel)",
699+
"display_name": "pyclass",
700700
"language": "python",
701701
"name": "python3"
702+
},
703+
"language_info": {
704+
"codemirror_mode": {
705+
"name": "ipython",
706+
"version": 3
707+
},
708+
"file_extension": ".py",
709+
"mimetype": "text/x-python",
710+
"name": "python",
711+
"nbconvert_exporter": "python",
712+
"pygments_lexer": "ipython3",
713+
"version": "3.14.3"
702714
}
703715
},
704716
"nbformat": 4,

notebooks/part1_flopy/solutions/03_Loading_and_visualizing_models-solutions.ipynb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@
10211021
"metadata": {},
10221022
"outputs": [],
10231023
"source": [
1024-
"pd.read_csv(sim_ws / 'external/chd_001.dat', delim_whitespace=True)"
1024+
"pd.read_csv(sim_ws / 'external/chd_001.dat', sep=r'\\s+')"
10251025
]
10261026
},
10271027
{
@@ -1130,6 +1130,10 @@
11301130
"fig, ax = plt.subplots(figsize=(10, 5))\n",
11311131
"in_cols = ['STO-SS_IN', 'STO-SY_IN', 'WEL_IN', 'RCHA_IN', 'CHD_IN', 'SFR_IN', 'LAK_IN']\n",
11321132
"out_cols = [c.replace('_IN', '_OUT') for c in in_cols]\n",
1133+
"# as of pandas 3.0.1, \n",
1134+
"# the datatime index of the flux dataframe produced by Flopy produces an error with .plot.bar();\n",
1135+
"# switch the index to a categorical (date string) index instead\n",
1136+
"flux.index = flux.index.strftime('%Y-%m-%d')\n",
11331137
"flux[in_cols].plot.bar(stacked=True, ax=ax)\n",
11341138
"(-flux[out_cols]).plot.bar(stacked=True, ax=ax)\n",
11351139
"ax.legend(loc='lower left', bbox_to_anchor=(1, 0))\n",
@@ -1172,7 +1176,7 @@
11721176
"name": "python",
11731177
"nbconvert_exporter": "python",
11741178
"pygments_lexer": "ipython3",
1175-
"version": "3.12.11"
1179+
"version": "3.14.3"
11761180
}
11771181
},
11781182
"nbformat": 4,

notebooks/part1_flopy/solutions/07-stream_capture_voronoi.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13158,7 +13158,7 @@
1315813158
},
1315913159
{
1316013160
"cell_type": "code",
13161-
"execution_count": 47,
13161+
"execution_count": null,
1316213162
"id": "fd8e62ba",
1316313163
"metadata": {},
1316413164
"outputs": [
@@ -13180,8 +13180,8 @@
1318013180
"for gage_num in range(2):\n",
1318113181
" for lay_num in range(3):\n",
1318213182
" cax = ax[ax_num]\n",
13183-
" data = drf.loc[lay_num][f'Gage{gage_num+1}'].values\n",
13184-
" data[data<0] =0\n",
13183+
" data = drf.loc[lay_num][f'Gage{gage_num+1}'].values.copy()\n",
13184+
" data[data < 0] = 0\n",
1318513185
" mm = fp.plot.PlotMapView(model= base_m, ax=cax)\n",
1318613186
" mm.plot_bc('SFR', plotAll=True, color='blue')\n",
1318713187
" mm.plot_bc('WEL', plotAll=True)\n",

0 commit comments

Comments
 (0)