From 9d16093ab3efa9a15109834dd5f73d3e3e2f11e7 Mon Sep 17 00:00:00 2001 From: Sara Shinde <170439346+sara-shinde@users.noreply.github.com> Date: Sat, 1 Aug 2026 11:50:11 +0300 Subject: [PATCH 1/2] Replace deprecated applymap() with map() DataFrame.applymap() was deprecated and renamed to DataFrame.map() in pandas version 2.1.0. --- .../Exercises_with_solutions.ipynb | 224 ++++++++++-------- 1 file changed, 126 insertions(+), 98 deletions(-) diff --git a/04_Apply/Students_Alcohol_Consumption/Exercises_with_solutions.ipynb b/04_Apply/Students_Alcohol_Consumption/Exercises_with_solutions.ipynb index 41645d028..d1dead18e 100644 --- a/04_Apply/Students_Alcohol_Consumption/Exercises_with_solutions.ipynb +++ b/04_Apply/Students_Alcohol_Consumption/Exercises_with_solutions.ipynb @@ -20,7 +20,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 12, "metadata": { "collapsed": false }, @@ -46,7 +46,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 13, "metadata": { "collapsed": false, "scrolled": false @@ -56,6 +56,19 @@ "data": { "text/html": [ "
\n", + "\n", "\n", " \n", " \n", @@ -210,12 +223,12 @@ "" ], "text/plain": [ - " school sex age address famsize Pstatus Medu Fedu Mjob Fjob ... \\\n", - "0 GP F 18 U GT3 A 4 4 at_home teacher ... \n", - "1 GP F 17 U GT3 T 1 1 at_home other ... \n", - "2 GP F 15 U LE3 T 1 1 at_home other ... \n", - "3 GP F 15 U GT3 T 4 2 health services ... \n", - "4 GP F 16 U GT3 T 3 3 other other ... \n", + " school sex age address famsize Pstatus Medu Fedu Mjob Fjob ... \\\n", + "0 GP F 18 U GT3 A 4 4 at_home teacher ... \n", + "1 GP F 17 U GT3 T 1 1 at_home other ... \n", + "2 GP F 15 U LE3 T 1 1 at_home other ... \n", + "3 GP F 15 U GT3 T 4 2 health services ... \n", + "4 GP F 16 U GT3 T 3 3 other other ... \n", "\n", " famrel freetime goout Dalc Walc health absences G1 G2 G3 \n", "0 4 3 4 1 1 3 6 5 6 6 \n", @@ -227,7 +240,7 @@ "[5 rows x 33 columns]" ] }, - "execution_count": 2, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -247,7 +260,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 14, "metadata": { "collapsed": false }, @@ -256,6 +269,19 @@ "data": { "text/html": [ "
\n", + "\n", "
\n", " \n", " \n", @@ -370,7 +396,7 @@ "4 home father " ] }, - "execution_count": 3, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -389,7 +415,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 15, "metadata": { "collapsed": false }, @@ -407,7 +433,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 16, "metadata": { "collapsed": false }, @@ -420,66 +446,16 @@ "2 Other\n", "3 Services\n", "4 Other\n", - "5 Other\n", - "6 Other\n", - "7 Teacher\n", - "8 Other\n", - "9 Other\n", - "10 Health\n", - "11 Other\n", - "12 Services\n", - "13 Other\n", - "14 Other\n", - "15 Other\n", - "16 Services\n", - "17 Other\n", - "18 Services\n", - "19 Other\n", - "20 Other\n", - "21 Health\n", - "22 Other\n", - "23 Other\n", - "24 Health\n", - "25 Services\n", - "26 Other\n", - "27 Services\n", - "28 Other\n", - "29 Teacher\n", " ... \n", - "365 Other\n", - "366 Services\n", - "367 Services\n", - "368 Services\n", - "369 Teacher\n", - "370 Services\n", - "371 Services\n", - "372 At_home\n", - "373 Other\n", - "374 Other\n", - "375 Other\n", - "376 Other\n", - "377 Services\n", - "378 Other\n", - "379 Other\n", - "380 Teacher\n", - "381 Other\n", - "382 Services\n", - "383 Services\n", - "384 Other\n", - "385 Other\n", - "386 At_home\n", - "387 Other\n", - "388 Services\n", - "389 Other\n", "390 Services\n", "391 Services\n", "392 Other\n", "393 Other\n", "394 At_home\n", - "Name: Fjob, dtype: object" + "Name: Fjob, Length: 395, dtype: str" ] }, - "execution_count": 11, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -498,7 +474,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 17, "metadata": { "collapsed": false }, @@ -507,6 +483,19 @@ "data": { "text/html": [ "
\n", + "\n", "
\n", " \n", " \n", @@ -621,7 +610,7 @@ "394 course father " ] }, - "execution_count": 12, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -639,7 +628,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 18, "metadata": { "collapsed": false }, @@ -648,6 +637,19 @@ "data": { "text/html": [ "
\n", + "\n", "
\n", " \n", " \n", @@ -762,7 +764,7 @@ "394 course father " ] }, - "execution_count": 13, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -782,7 +784,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 19, "metadata": { "collapsed": false }, @@ -797,7 +799,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 20, "metadata": { "collapsed": false }, @@ -806,6 +808,19 @@ "data": { "text/html": [ "
\n", + "\n", "
\n", " \n", " \n", @@ -918,15 +933,15 @@ "3 GP F 15 U GT3 T 4 2 Health Services \n", "4 GP F 16 U GT3 T 3 3 Other Other \n", "\n", - " reason guardian legal_drinker \n", - "0 course mother True \n", - "1 course father False \n", - "2 other mother False \n", - "3 home mother False \n", - "4 home father False " + " reason guardian legal_drinker \n", + "0 course mother True \n", + "1 course father False \n", + "2 other mother False \n", + "3 home mother False \n", + "4 home father False " ] }, - "execution_count": 15, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -946,7 +961,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 21, "metadata": { "collapsed": false }, @@ -960,7 +975,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 22, "metadata": { "collapsed": false }, @@ -969,6 +984,19 @@ "data": { "text/html": [ "
\n", + "\n", "
\n", " \n", " \n", @@ -1166,47 +1194,47 @@ "8 GP M 150 U LE3 A 30 20 Services Other \n", "9 GP M 150 U GT3 T 30 40 Other Other \n", "\n", - " reason guardian legal_drinker \n", - "0 course mother True \n", - "1 course father False \n", - "2 other mother False \n", - "3 home mother False \n", - "4 home father False \n", - "5 reputation mother False \n", - "6 home mother False \n", - "7 home mother False \n", - "8 home mother False \n", - "9 home mother False " + " reason guardian legal_drinker \n", + "0 course mother True \n", + "1 course father False \n", + "2 other mother False \n", + "3 home mother False \n", + "4 home father False \n", + "5 reputation mother False \n", + "6 home mother False \n", + "7 home mother False \n", + "8 home mother False \n", + "9 home mother False " ] }, - "execution_count": 17, + "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "stud_alcoh.applymap(times10).head(10)" + "stud_alcoh.map(times10).head(10)" ] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { - "display_name": "Python [default]", + "display_name": "cpython-3.14.5-windows-x86_64-none (3.14.5)", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.12" + "pygments_lexer": "ipython3", + "version": "3.14.5" } }, "nbformat": 4, From 9564887de55f806966d1def6e5c1c7213ed6393b Mon Sep 17 00:00:00 2001 From: Sara Shinde <170439346+sara-shinde@users.noreply.github.com> Date: Sat, 1 Aug 2026 12:29:51 +0300 Subject: [PATCH 2/2] Reduce diff to just the applymap -> map fix --- .../Exercises_with_solutions.ipynb | 216 ++++++++---------- 1 file changed, 94 insertions(+), 122 deletions(-) diff --git a/04_Apply/Students_Alcohol_Consumption/Exercises_with_solutions.ipynb b/04_Apply/Students_Alcohol_Consumption/Exercises_with_solutions.ipynb index d1dead18e..a84705e63 100644 --- a/04_Apply/Students_Alcohol_Consumption/Exercises_with_solutions.ipynb +++ b/04_Apply/Students_Alcohol_Consumption/Exercises_with_solutions.ipynb @@ -20,7 +20,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 1, "metadata": { "collapsed": false }, @@ -46,7 +46,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 2, "metadata": { "collapsed": false, "scrolled": false @@ -56,19 +56,6 @@ "data": { "text/html": [ "
\n", - "\n", "
\n", " \n", " \n", @@ -223,12 +210,12 @@ "" ], "text/plain": [ - " school sex age address famsize Pstatus Medu Fedu Mjob Fjob ... \\\n", - "0 GP F 18 U GT3 A 4 4 at_home teacher ... \n", - "1 GP F 17 U GT3 T 1 1 at_home other ... \n", - "2 GP F 15 U LE3 T 1 1 at_home other ... \n", - "3 GP F 15 U GT3 T 4 2 health services ... \n", - "4 GP F 16 U GT3 T 3 3 other other ... \n", + " school sex age address famsize Pstatus Medu Fedu Mjob Fjob ... \\\n", + "0 GP F 18 U GT3 A 4 4 at_home teacher ... \n", + "1 GP F 17 U GT3 T 1 1 at_home other ... \n", + "2 GP F 15 U LE3 T 1 1 at_home other ... \n", + "3 GP F 15 U GT3 T 4 2 health services ... \n", + "4 GP F 16 U GT3 T 3 3 other other ... \n", "\n", " famrel freetime goout Dalc Walc health absences G1 G2 G3 \n", "0 4 3 4 1 1 3 6 5 6 6 \n", @@ -240,7 +227,7 @@ "[5 rows x 33 columns]" ] }, - "execution_count": 13, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -260,7 +247,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 3, "metadata": { "collapsed": false }, @@ -269,19 +256,6 @@ "data": { "text/html": [ "
\n", - "\n", "
\n", " \n", " \n", @@ -396,7 +370,7 @@ "4 home father " ] }, - "execution_count": 14, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -415,7 +389,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 10, "metadata": { "collapsed": false }, @@ -433,7 +407,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 11, "metadata": { "collapsed": false }, @@ -446,16 +420,66 @@ "2 Other\n", "3 Services\n", "4 Other\n", + "5 Other\n", + "6 Other\n", + "7 Teacher\n", + "8 Other\n", + "9 Other\n", + "10 Health\n", + "11 Other\n", + "12 Services\n", + "13 Other\n", + "14 Other\n", + "15 Other\n", + "16 Services\n", + "17 Other\n", + "18 Services\n", + "19 Other\n", + "20 Other\n", + "21 Health\n", + "22 Other\n", + "23 Other\n", + "24 Health\n", + "25 Services\n", + "26 Other\n", + "27 Services\n", + "28 Other\n", + "29 Teacher\n", " ... \n", + "365 Other\n", + "366 Services\n", + "367 Services\n", + "368 Services\n", + "369 Teacher\n", + "370 Services\n", + "371 Services\n", + "372 At_home\n", + "373 Other\n", + "374 Other\n", + "375 Other\n", + "376 Other\n", + "377 Services\n", + "378 Other\n", + "379 Other\n", + "380 Teacher\n", + "381 Other\n", + "382 Services\n", + "383 Services\n", + "384 Other\n", + "385 Other\n", + "386 At_home\n", + "387 Other\n", + "388 Services\n", + "389 Other\n", "390 Services\n", "391 Services\n", "392 Other\n", "393 Other\n", "394 At_home\n", - "Name: Fjob, Length: 395, dtype: str" + "Name: Fjob, dtype: object" ] }, - "execution_count": 16, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -474,7 +498,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 12, "metadata": { "collapsed": false }, @@ -483,19 +507,6 @@ "data": { "text/html": [ "
\n", - "\n", "
\n", " \n", " \n", @@ -610,7 +621,7 @@ "394 course father " ] }, - "execution_count": 17, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -628,7 +639,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 13, "metadata": { "collapsed": false }, @@ -637,19 +648,6 @@ "data": { "text/html": [ "
\n", - "\n", "
\n", " \n", " \n", @@ -764,7 +762,7 @@ "394 course father " ] }, - "execution_count": 18, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -784,7 +782,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 14, "metadata": { "collapsed": false }, @@ -799,7 +797,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 15, "metadata": { "collapsed": false }, @@ -808,19 +806,6 @@ "data": { "text/html": [ "
\n", - "\n", "
\n", " \n", " \n", @@ -933,15 +918,15 @@ "3 GP F 15 U GT3 T 4 2 Health Services \n", "4 GP F 16 U GT3 T 3 3 Other Other \n", "\n", - " reason guardian legal_drinker \n", - "0 course mother True \n", - "1 course father False \n", - "2 other mother False \n", - "3 home mother False \n", - "4 home father False " + " reason guardian legal_drinker \n", + "0 course mother True \n", + "1 course father False \n", + "2 other mother False \n", + "3 home mother False \n", + "4 home father False " ] }, - "execution_count": 20, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -961,7 +946,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 16, "metadata": { "collapsed": false }, @@ -975,7 +960,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": null, "metadata": { "collapsed": false }, @@ -984,19 +969,6 @@ "data": { "text/html": [ "
\n", - "\n", "
\n", " \n", " \n", @@ -1194,20 +1166,20 @@ "8 GP M 150 U LE3 A 30 20 Services Other \n", "9 GP M 150 U GT3 T 30 40 Other Other \n", "\n", - " reason guardian legal_drinker \n", - "0 course mother True \n", - "1 course father False \n", - "2 other mother False \n", - "3 home mother False \n", - "4 home father False \n", - "5 reputation mother False \n", - "6 home mother False \n", - "7 home mother False \n", - "8 home mother False \n", - "9 home mother False " + " reason guardian legal_drinker \n", + "0 course mother True \n", + "1 course father False \n", + "2 other mother False \n", + "3 home mother False \n", + "4 home father False \n", + "5 reputation mother False \n", + "6 home mother False \n", + "7 home mother False \n", + "8 home mother False \n", + "9 home mother False " ] }, - "execution_count": 22, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -1227,13 +1199,13 @@ "language_info": { "codemirror_mode": { "name": "ipython", - "version": 3 + "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", + "pygments_lexer": "ipython2", "version": "3.14.5" } },