Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
214 changes: 121 additions & 93 deletions 04_Apply/Students_Alcohol_Consumption/Exercises_with_solutions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
Expand Down Expand Up @@ -210,12 +223,12 @@
"</div>"
],
"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",
Expand Down Expand Up @@ -256,6 +269,19 @@
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
Expand Down Expand Up @@ -389,7 +415,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 4,
"metadata": {
"collapsed": false
},
Expand All @@ -407,7 +433,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 5,
"metadata": {
"collapsed": false
},
Expand All @@ -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: object"
]
},
"execution_count": 11,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -498,7 +474,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 6,
"metadata": {
"collapsed": false
},
Expand All @@ -507,6 +483,19 @@
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
Expand Down Expand Up @@ -621,7 +610,7 @@
"394 course father "
]
},
"execution_count": 12,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -639,7 +628,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 7,
"metadata": {
"collapsed": false
},
Expand All @@ -648,6 +637,19 @@
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
Expand Down Expand Up @@ -762,7 +764,7 @@
"394 course father "
]
},
"execution_count": 13,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -782,7 +784,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 8,
"metadata": {
"collapsed": false
},
Expand All @@ -797,7 +799,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 9,
"metadata": {
"collapsed": false
},
Expand All @@ -806,6 +808,19 @@
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
Expand Down Expand Up @@ -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": 9,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -946,7 +961,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 10,
"metadata": {
"collapsed": false
},
Expand All @@ -960,7 +975,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 13,
"metadata": {
"collapsed": false
},
Expand All @@ -969,6 +984,19 @@
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
Expand Down Expand Up @@ -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": 13,
"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": "base",
"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.12.7"
}
},
"nbformat": 4,
Expand Down