Skip to content

Commit 6bfd546

Browse files
committed
Fix FutureWarnings by replacing deprecated Series.agg with Series.transform in Pandas.ipynb
1 parent dff4bda commit 6bfd546

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

4-Pandas_Overview/Pandas.ipynb

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4634,20 +4634,12 @@
46344634
"5 0.4\n",
46354635
"dtype: float64\n"
46364636
]
4637-
},
4638-
{
4639-
"name": "stderr",
4640-
"output_type": "stream",
4641-
"text": [
4642-
"/tmp/ipykernel_281901/4232142427.py:3: FutureWarning: using <ufunc 'absolute'> in Series.agg cannot aggregate and has been deprecated. Use Series.transform to keep behavior unchanged.\n",
4643-
" b = a.agg(np.abs)\n"
4644-
]
46454637
}
46464638
],
46474639
"source": [
46484640
"import numpy as np\n",
46494641
"a = pd.Series(range(-1,5))\n",
4650-
"b = a.agg(np.abs)\n",
4642+
"b = a.transform(np.abs)\n",
46514643
"c = a.transform(lambda x: x/10.0)\n",
46524644
"print(a)\n",
46534645
"print(b)\n",
@@ -4825,20 +4817,12 @@
48254817
"a.any(): False\n",
48264818
"b.any(): True\n"
48274819
]
4828-
},
4829-
{
4830-
"name": "stderr",
4831-
"output_type": "stream",
4832-
"text": [
4833-
"/tmp/ipykernel_281901/445209018.py:3: FutureWarning: Setting an item of incompatible dtype is deprecated and will raise an error in a future version of pandas. Value '10' has dtype incompatible with bool, please explicitly cast to a compatible dtype first.\n",
4834-
" b[3] = 10\n"
4835-
]
48364820
}
48374821
],
48384822
"source": [
48394823
"a = pd.Series([False]*5)\n",
48404824
"b = pd.Series([False]*5)\n",
4841-
"b[3] = 10\n",
4825+
"b[3] = True\n",
48424826
"print(\"a.any(): {}\".format(a.any()))\n",
48434827
"print(\"b.any(): {}\".format(b.any()))"
48444828
]

0 commit comments

Comments
 (0)