Created
December 2, 2022 07:41
-
-
Save Evgenion47/4a2cd142c5cb731a14b1852195777be3 to your computer and use it in GitHub Desktop.
Копия блокнота "Задание 1.2 Анализ данных в Python.ipynb""
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.3" | |
}, | |
"colab": { | |
"provenance": [], | |
"include_colab_link": true | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/Evgenion47/4a2cd142c5cb731a14b1852195777be3/-1-2-python-ipynb.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "DVuzDDo5XDcH", | |
"outputId": "97767b71-7ddb-44dc-d876-153c763e7ce0", | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
} | |
}, | |
"source": [ | |
"# скачиваем файл\n", | |
"!wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=1cq9JDz8-zwzoGL6udiT_ogHHRWdnsd1q' -O math_students.csv" | |
], | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"--2022-12-02 07:39:07-- https://docs.google.com/uc?export=download&id=1cq9JDz8-zwzoGL6udiT_ogHHRWdnsd1q\n", | |
"Resolving docs.google.com (docs.google.com)... 74.125.197.139, 74.125.197.101, 74.125.197.138, ...\n", | |
"Connecting to docs.google.com (docs.google.com)|74.125.197.139|:443... connected.\n", | |
"HTTP request sent, awaiting response... 303 See Other\n", | |
"Location: https://doc-0g-5k-docs.googleusercontent.com/docs/securesc/ha0ro937gcuc7l7deffksulhg5h7mbp1/7ggi717roil81u5uoriuug3me0rji299/1669966725000/07828702499945486090/*/1cq9JDz8-zwzoGL6udiT_ogHHRWdnsd1q?e=download&uuid=17b47961-8cfc-4d4e-a7a1-102c9faafc57 [following]\n", | |
"Warning: wildcards not supported in HTTP.\n", | |
"--2022-12-02 07:39:08-- https://doc-0g-5k-docs.googleusercontent.com/docs/securesc/ha0ro937gcuc7l7deffksulhg5h7mbp1/7ggi717roil81u5uoriuug3me0rji299/1669966725000/07828702499945486090/*/1cq9JDz8-zwzoGL6udiT_ogHHRWdnsd1q?e=download&uuid=17b47961-8cfc-4d4e-a7a1-102c9faafc57\n", | |
"Resolving doc-0g-5k-docs.googleusercontent.com (doc-0g-5k-docs.googleusercontent.com)... 74.125.195.132, 2607:f8b0:400e:c09::84\n", | |
"Connecting to doc-0g-5k-docs.googleusercontent.com (doc-0g-5k-docs.googleusercontent.com)|74.125.195.132|:443... connected.\n", | |
"HTTP request sent, awaiting response... 200 OK\n", | |
"Length: 42379 (41K) [text/csv]\n", | |
"Saving to: ‘math_students.csv’\n", | |
"\n", | |
"math_students.csv 100%[===================>] 41.39K --.-KB/s in 0.001s \n", | |
"\n", | |
"2022-12-02 07:39:08 (45.2 MB/s) - ‘math_students.csv’ saved [42379/42379]\n", | |
"\n" | |
] | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "mHCbkFpOXAXO" | |
}, | |
"source": [ | |
"import pandas as pd\n", | |
"data = pd.read_csv('math_students.csv', delimiter=',')" | |
], | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "K2n8-KlAwKUq", | |
"outputId": "f824f114-35b5-4352-c934-d22a7a9ec012", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 236 | |
} | |
}, | |
"source": [ | |
"data.head()" | |
], | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"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", | |
"\n", | |
" famrel freetime goout Dalc Walc health absences G1 G2 G3 \n", | |
"0 4 3 4 1 1 3 6 5 6 6 \n", | |
"1 5 3 3 1 1 3 4 5 5 6 \n", | |
"2 4 3 2 2 3 3 10 7 8 10 \n", | |
"3 3 2 2 1 1 5 2 15 14 15 \n", | |
"4 4 3 2 1 2 5 4 6 10 10 \n", | |
"\n", | |
"[5 rows x 33 columns]" | |
], | |
"text/html": [ | |
"\n", | |
" <div id=\"df-a5ebd5f1-e84d-4b1b-ae23-764a623b120b\">\n", | |
" <div class=\"colab-df-container\">\n", | |
" <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", | |
" <th></th>\n", | |
" <th>school</th>\n", | |
" <th>sex</th>\n", | |
" <th>age</th>\n", | |
" <th>address</th>\n", | |
" <th>famsize</th>\n", | |
" <th>Pstatus</th>\n", | |
" <th>Medu</th>\n", | |
" <th>Fedu</th>\n", | |
" <th>Mjob</th>\n", | |
" <th>Fjob</th>\n", | |
" <th>...</th>\n", | |
" <th>famrel</th>\n", | |
" <th>freetime</th>\n", | |
" <th>goout</th>\n", | |
" <th>Dalc</th>\n", | |
" <th>Walc</th>\n", | |
" <th>health</th>\n", | |
" <th>absences</th>\n", | |
" <th>G1</th>\n", | |
" <th>G2</th>\n", | |
" <th>G3</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>GP</td>\n", | |
" <td>F</td>\n", | |
" <td>18</td>\n", | |
" <td>U</td>\n", | |
" <td>GT3</td>\n", | |
" <td>A</td>\n", | |
" <td>4</td>\n", | |
" <td>4</td>\n", | |
" <td>at_home</td>\n", | |
" <td>teacher</td>\n", | |
" <td>...</td>\n", | |
" <td>4</td>\n", | |
" <td>3</td>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" <td>1</td>\n", | |
" <td>3</td>\n", | |
" <td>6</td>\n", | |
" <td>5</td>\n", | |
" <td>6</td>\n", | |
" <td>6</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>GP</td>\n", | |
" <td>F</td>\n", | |
" <td>17</td>\n", | |
" <td>U</td>\n", | |
" <td>GT3</td>\n", | |
" <td>T</td>\n", | |
" <td>1</td>\n", | |
" <td>1</td>\n", | |
" <td>at_home</td>\n", | |
" <td>other</td>\n", | |
" <td>...</td>\n", | |
" <td>5</td>\n", | |
" <td>3</td>\n", | |
" <td>3</td>\n", | |
" <td>1</td>\n", | |
" <td>1</td>\n", | |
" <td>3</td>\n", | |
" <td>4</td>\n", | |
" <td>5</td>\n", | |
" <td>5</td>\n", | |
" <td>6</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>GP</td>\n", | |
" <td>F</td>\n", | |
" <td>15</td>\n", | |
" <td>U</td>\n", | |
" <td>LE3</td>\n", | |
" <td>T</td>\n", | |
" <td>1</td>\n", | |
" <td>1</td>\n", | |
" <td>at_home</td>\n", | |
" <td>other</td>\n", | |
" <td>...</td>\n", | |
" <td>4</td>\n", | |
" <td>3</td>\n", | |
" <td>2</td>\n", | |
" <td>2</td>\n", | |
" <td>3</td>\n", | |
" <td>3</td>\n", | |
" <td>10</td>\n", | |
" <td>7</td>\n", | |
" <td>8</td>\n", | |
" <td>10</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>GP</td>\n", | |
" <td>F</td>\n", | |
" <td>15</td>\n", | |
" <td>U</td>\n", | |
" <td>GT3</td>\n", | |
" <td>T</td>\n", | |
" <td>4</td>\n", | |
" <td>2</td>\n", | |
" <td>health</td>\n", | |
" <td>services</td>\n", | |
" <td>...</td>\n", | |
" <td>3</td>\n", | |
" <td>2</td>\n", | |
" <td>2</td>\n", | |
" <td>1</td>\n", | |
" <td>1</td>\n", | |
" <td>5</td>\n", | |
" <td>2</td>\n", | |
" <td>15</td>\n", | |
" <td>14</td>\n", | |
" <td>15</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>GP</td>\n", | |
" <td>F</td>\n", | |
" <td>16</td>\n", | |
" <td>U</td>\n", | |
" <td>GT3</td>\n", | |
" <td>T</td>\n", | |
" <td>3</td>\n", | |
" <td>3</td>\n", | |
" <td>other</td>\n", | |
" <td>other</td>\n", | |
" <td>...</td>\n", | |
" <td>4</td>\n", | |
" <td>3</td>\n", | |
" <td>2</td>\n", | |
" <td>1</td>\n", | |
" <td>2</td>\n", | |
" <td>5</td>\n", | |
" <td>4</td>\n", | |
" <td>6</td>\n", | |
" <td>10</td>\n", | |
" <td>10</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"<p>5 rows × 33 columns</p>\n", | |
"</div>\n", | |
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-a5ebd5f1-e84d-4b1b-ae23-764a623b120b')\"\n", | |
" title=\"Convert this dataframe to an interactive table.\"\n", | |
" style=\"display:none;\">\n", | |
" \n", | |
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n", | |
" width=\"24px\">\n", | |
" <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n", | |
" <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n", | |
" </svg>\n", | |
" </button>\n", | |
" \n", | |
" <style>\n", | |
" .colab-df-container {\n", | |
" display:flex;\n", | |
" flex-wrap:wrap;\n", | |
" gap: 12px;\n", | |
" }\n", | |
"\n", | |
" .colab-df-convert {\n", | |
" background-color: #E8F0FE;\n", | |
" border: none;\n", | |
" border-radius: 50%;\n", | |
" cursor: pointer;\n", | |
" display: none;\n", | |
" fill: #1967D2;\n", | |
" height: 32px;\n", | |
" padding: 0 0 0 0;\n", | |
" width: 32px;\n", | |
" }\n", | |
"\n", | |
" .colab-df-convert:hover {\n", | |
" background-color: #E2EBFA;\n", | |
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n", | |
" fill: #174EA6;\n", | |
" }\n", | |
"\n", | |
" [theme=dark] .colab-df-convert {\n", | |
" background-color: #3B4455;\n", | |
" fill: #D2E3FC;\n", | |
" }\n", | |
"\n", | |
" [theme=dark] .colab-df-convert:hover {\n", | |
" background-color: #434B5C;\n", | |
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n", | |
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n", | |
" fill: #FFFFFF;\n", | |
" }\n", | |
" </style>\n", | |
"\n", | |
" <script>\n", | |
" const buttonEl =\n", | |
" document.querySelector('#df-a5ebd5f1-e84d-4b1b-ae23-764a623b120b button.colab-df-convert');\n", | |
" buttonEl.style.display =\n", | |
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n", | |
"\n", | |
" async function convertToInteractive(key) {\n", | |
" const element = document.querySelector('#df-a5ebd5f1-e84d-4b1b-ae23-764a623b120b');\n", | |
" const dataTable =\n", | |
" await google.colab.kernel.invokeFunction('convertToInteractive',\n", | |
" [key], {});\n", | |
" if (!dataTable) return;\n", | |
"\n", | |
" const docLinkHtml = 'Like what you see? Visit the ' +\n", | |
" '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n", | |
" + ' to learn more about interactive tables.';\n", | |
" element.innerHTML = '';\n", | |
" dataTable['output_type'] = 'display_data';\n", | |
" await google.colab.output.renderOutput(dataTable, element);\n", | |
" const docLink = document.createElement('div');\n", | |
" docLink.innerHTML = docLinkHtml;\n", | |
" element.appendChild(docLink);\n", | |
" }\n", | |
" </script>\n", | |
" </div>\n", | |
" </div>\n", | |
" " | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 4 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "bm9NoBIu1zxX", | |
"outputId": "bd3c5824-333a-47e6-fdbc-907fc77bdb64", | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
} | |
}, | |
"source": [ | |
"a=data.groupby('romantic')['G3'].mean()\n", | |
"a" | |
], | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"romantic\n", | |
"no 10.836502\n", | |
"yes 9.575758\n", | |
"Name: G3, dtype: float64" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 5 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "HLyly1-P2K1D", | |
"outputId": "20c7d6eb-c480-41ce-e1ae-46fb63f42ce8", | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
} | |
}, | |
"source": [ | |
"a[1]-a[0]" | |
], | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"-1.2607443253831079" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 6 | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "bHzHQnc-wl_s" | |
}, | |
"source": [ | |
"Описание признаков:\n", | |
"\n", | |
" - school - тип школы (\"GP\" - Gabriel Pereira или \"MS\" - Mousinho da Silveira)\n", | |
" - sex - пол (\"F\" - female или \"M\" - male)\n", | |
" - age - возраст (от 15 до 22)\n", | |
" - address - откуда студент (\"U\" - urban или \"R\" - rural)\n", | |
" - famsize - размер семьи (\"LE3\" - меньше или равно 3 или \"GT3\" - больше 3)\n", | |
" - Pstatus - в каких отношениях родители (\"T\" - живут вместе \"A\" - раздельно)\n", | |
" - Medu - образование матери (0 - никакого, 1 - начальное образование (4 класса), 2 – от 5 до 9 классов, 3 – среднеспециальное или 4 – высшее)\n", | |
" - Fedu - образование отца (0 - никакого, 1 - начальное образование (4 класса), 2 – от 5 до 9 классов, 3 – среднеспециальное или 4 – высшее)\n", | |
" - Mjob - работа матери (\"teacher\", \"health\" care related, civil \"services\" (e.g. administrative or police), \"at_home\" or \"other\")\n", | |
" - Fjob - работа отца (\"teacher\", \"health\" care related, civil \"services\" (e.g. administrative or police), \"at_home\" or \"other\")\n", | |
" - reason - причина выбора школы (близко к дому — \"home\", репутация школы — \"reputation\", предпочтение некоторым предметам - \"course\" или \"other\")\n", | |
" - guardian - опекун (\"mother\", \"father\" или \"other\")\n", | |
" - traveltime - время от дома до школы (1 - меньше 15 мин., 2 - 15 до 30 мин., 3 - 30 мин. до 1 часа, или 4 - больше 1 часа)\n", | |
" - studytime - количество часов обучения в неделю (1 - меньше 2 часов, 2 - от 2 до 5 часов, 3 - от 5 до 10 часов, или 4 - больше 10 часов)\n", | |
" - failures - количество ранее не сданных предметов (n if 1 <= n < 3, else 4)\n", | |
" - schoolsup - дополнительные занятия (yes or no)\n", | |
" - famsup - помощь от семьи при выполнении заданий (yes or no)\n", | |
" - paid - дополнительные платные занятия (yes or no)\n", | |
" - activities - внеклассная деятельность (yes or no)\n", | |
" - nursery - посещал детский сад (yes or no)\n", | |
" - higher - желание высшего образования (yes or no)\n", | |
" - internet - домашний интернет (yes or no)\n", | |
" - romantic - состоит в романтических отношениях (yes or no)\n", | |
" - famrel - насколько хороши отношения в семье (от 1 - очень плохие до 5 - превосходные)\n", | |
" - freetime - наличие свободного времени после школы (от 1 - очень мало до 5 - очень много)\n", | |
" - goout - гуляет с друзьями (от 1 - редко до 5 - очень часто)\n", | |
" - Dalc - употребление алкоголя в будние дни (от 1 - очень редко до 5 - очень часто)\n", | |
" - Walc - употребление алкоголя в выходные (от 1 - очень редко до 5 - очень часто)\n", | |
" - health - текущее состояние здоровья (от 1 - очень плохое до 5 - очень хорошее)\n", | |
" - absences - количество школьных пропусков (от 0 до 93)\n", | |
" - G1 - оценка за первый семестр (от 0 до 20)\n", | |
" - G2 - оценка за второй семестр (от 0 до 20)\n", | |
" - G3 - итоговая оценка (от 0 до 20)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "FjXxMpsbw19P" | |
}, | |
"source": [ | |
"#Задания" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "1n6Q2mr1XAXX" | |
}, | |
"source": [ | |
"1. Какая причина выбора школы была самой частой? В качестве ответа приведите соответствующее значение признака." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "D_jubmNgXAXY", | |
"outputId": "976b2c8c-434d-497e-a216-648e1e005e6b", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 35 | |
} | |
}, | |
"source": [ | |
"data['reason'].describe()['top']" | |
], | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"'course'" | |
], | |
"application/vnd.google.colaboratory.intrinsic+json": { | |
"type": "string" | |
} | |
}, | |
"metadata": {}, | |
"execution_count": 7 | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "02xcWVw0XAXb" | |
}, | |
"source": [ | |
"2. Найдите количество студентов, у родителей которых нет никакого образования." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "rQCZTAydXAXc", | |
"outputId": "050e06ac-f843-4dd7-b1b3-d7e19022e6bb", | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
} | |
}, | |
"source": [ | |
"data[(data['Fedu'] == 0) & (data['Medu'] == 0)].shape[0]" | |
], | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"0" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 8 | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "hPZhCWolXAXg" | |
}, | |
"source": [ | |
"3. Найдите минимальный возраст учащегося школы Mousinho da Silveira." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "iwbblqO-XAXg", | |
"outputId": "472b887c-3248-4b31-9b02-8062df26bb2b", | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
} | |
}, | |
"source": [ | |
"data[data['school'] == 'MS']['age'].min()" | |
], | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"17" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 9 | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "cINy8kq-XAXk" | |
}, | |
"source": [ | |
"4. Найдите количество студентов, имеющих нечетное число пропусков." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "0SPhqD6GXAXl", | |
"outputId": "e5c64bba-c231-4d63-862d-b7f9590a704c", | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
} | |
}, | |
"source": [ | |
"data[data['absences'] % 2 == 1].shape[0]" | |
], | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"41" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 10 | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "cGd3eKvcXAXo" | |
}, | |
"source": [ | |
"5. Найдите разность между средними итоговыми оценками студентов, состоящих и не состоящих в романтических отношениях. В качестве ответа приведите число, округленное до двух значащих цифр после запятой." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "tIrAEaCpXAXp", | |
"outputId": "a391ff42-0d41-4956-fbe3-6431a1a0d450", | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
} | |
}, | |
"source": [ | |
"rom = data.groupby('romantic')['G3'].mean()\n", | |
"rom['no'] - rom['yes']" | |
], | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"1.2607443253831079" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 11 | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "m7tyMSA7XAXs" | |
}, | |
"source": [ | |
"6. Сколько занятий пропустило большинство студентов с самым частым значением наличия внеклассных активностей?\n", | |
"\n", | |
"*Примечание. В данном контексте под \"большинством\" подразумеваются студенты, имеющее самое частое значение пропусков. То есть в данном задании необходимо:*\n", | |
"\n", | |
"\n", | |
"* *Определить самое частое значение наличия внеклассных активностей (да или нет).*\n", | |
"* *Для группы студентов, соответствующей этому значению, рассмотреть значения признака «число пропусков».*\n", | |
"* *Для каждого значения числа пропусков посчитать, сколько студентов ему соответствует.*\n", | |
"* *Выбрать значение числа пропусков с наибольшим числом студентов.*\n", | |
"\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "-nb9pAmdX4G9", | |
"outputId": "dccfd913-f6b2-4bff-a6a2-c7c6ab5a55f8", | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
} | |
}, | |
"source": [ | |
"data['activities'].value_counts()\n", | |
"data[data['activities'] == 'yes']['absences'].value_counts().index[0]" | |
], | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"0" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 12 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "AnmTjizAN3LW", | |
"outputId": "483d41ba-3da2-485b-ecff-db06791f88a6", | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
} | |
}, | |
"source": [ | |
"9.575-10.837" | |
], | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"-1.2620000000000005" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 13 | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment