{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "408fac83-b762-41bb-beb7-59734bdb6b7a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello, JupyterLab!\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello, JupyterLab!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bca21025-7277-428d-83ce-6f267a8433ee",
   "metadata": {},
   "source": [
    "# Анализ и визуализация данных\n",
    "## Практическая работа №3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "d957035a-5e0e-4e69-9a5b-151e2b8c9331",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Библиотеки успешно загружены!\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "from tqdm import tqdm\n",
    "\n",
    "print(\"Библиотеки успешно загружены!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "8aa0a31c-51aa-4c0e-afad-834889409d6a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Первый взгляд на данные:\n",
      "      Имя  Возраст  Баллы\n",
      "0    Анна       21     89\n",
      "1   Борис       22     76\n",
      "2  Виктор       23     95\n",
      "3  Галина       24     82\n",
      "<class 'pandas.DataFrame'>\n",
      "RangeIndex: 4 entries, 0 to 3\n",
      "Data columns (total 3 columns):\n",
      " #   Column   Non-Null Count  Dtype\n",
      "---  ------   --------------  -----\n",
      " 0   Имя      4 non-null      str  \n",
      " 1   Возраст  4 non-null      int64\n",
      " 2   Баллы    4 non-null      int64\n",
      "dtypes: int64(2), str(1)\n",
      "memory usage: 228.0 bytes\n",
      "None\n",
      "         Возраст      Баллы\n",
      "count   4.000000   4.000000\n",
      "mean   22.500000  85.500000\n",
      "std     1.290994   8.266398\n",
      "min    21.000000  76.000000\n",
      "25%    21.750000  80.500000\n",
      "50%    22.500000  85.500000\n",
      "75%    23.250000  90.500000\n",
      "max    24.000000  95.000000\n",
      "Имя        0\n",
      "Возраст    0\n",
      "Баллы      0\n",
      "dtype: int64\n"
     ]
    }
   ],
   "source": [
    "# Создадим DataFrame\n",
    "data = {\n",
    "    \"Имя\": [\"Анна\", \"Борис\", \"Виктор\", \"Галина\"],\n",
    "    \"Возраст\": [21, 22, 23, 24],\n",
    "    \"Баллы\": [89, 76, 95, 82]\n",
    "}\n",
    "df = pd.DataFrame(data)\n",
    "\n",
    "print(\"Первый взгляд на данные:\")\n",
    "print(df.head())\n",
    "print(df.info())\n",
    "print(df.describe())\n",
    "print(df.isnull().sum())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "c424e0ec-3356-4812-a8d8-5394d5de5f55",
   "metadata": {},
   "outputs": [
    {
     "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",
       "      <th></th>\n",
       "      <th>Имя</th>\n",
       "      <th>Возраст</th>\n",
       "      <th>Баллы</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Анна</td>\n",
       "      <td>21</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Борис</td>\n",
       "      <td>22</td>\n",
       "      <td>76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Виктор</td>\n",
       "      <td>23</td>\n",
       "      <td>95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Галина</td>\n",
       "      <td>24</td>\n",
       "      <td>82</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Имя  Возраст  Баллы\n",
       "0    Анна       21     89\n",
       "1   Борис       22     76\n",
       "2  Виктор       23     95\n",
       "3  Галина       24     82"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "169bbe9a-3bec-4d8b-a76c-a6385abc0586",
   "metadata": {},
   "outputs": [
    {
     "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",
       "      <th></th>\n",
       "      <th>Имя</th>\n",
       "      <th>Возраст</th>\n",
       "      <th>Баллы</th>\n",
       "      <th>Новый столбец</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Анна</td>\n",
       "      <td>21</td>\n",
       "      <td>89</td>\n",
       "      <td>97.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Борис</td>\n",
       "      <td>22</td>\n",
       "      <td>76</td>\n",
       "      <td>83.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Виктор</td>\n",
       "      <td>23</td>\n",
       "      <td>95</td>\n",
       "      <td>104.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Галина</td>\n",
       "      <td>24</td>\n",
       "      <td>82</td>\n",
       "      <td>90.2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Имя  Возраст  Баллы  Новый столбец\n",
       "0    Анна       21     89           97.9\n",
       "1   Борис       22     76           83.6\n",
       "2  Виктор       23     95          104.5\n",
       "3  Галина       24     82           90.2"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"Новый столбец\"] = df[\"Баллы\"] * 1.1\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "bf99305f-56f2-4d3f-86ba-c2086dd1e6ff",
   "metadata": {},
   "outputs": [
    {
     "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 tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr:last-of-type th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th colspan=\"3\" halign=\"left\">Баллы</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th></th>\n",
       "      <th>mean</th>\n",
       "      <th>max</th>\n",
       "      <th>min</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Категория</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>92.0</td>\n",
       "      <td>95</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>79.0</td>\n",
       "      <td>82</td>\n",
       "      <td>76</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          Баллы        \n",
       "           mean max min\n",
       "Категория              \n",
       "A          92.0  95  89\n",
       "B          79.0  82  76"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Сначала добавим категории для группировки\n",
    "df[\"Категория\"] = [\"A\", \"B\", \"A\", \"B\"]\n",
    "df.groupby(\"Категория\").agg({\"Баллы\": [\"mean\", \"max\", \"min\"]})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "af433a96-0fd2-4ec1-9893-239cbc509c3c",
   "metadata": {},
   "outputs": [
    {
     "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",
       "      <th></th>\n",
       "      <th>Имя</th>\n",
       "      <th>Возраст</th>\n",
       "      <th>Баллы</th>\n",
       "      <th>Новый столбец</th>\n",
       "      <th>Категория</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Борис</td>\n",
       "      <td>22</td>\n",
       "      <td>76</td>\n",
       "      <td>83.6</td>\n",
       "      <td>B</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Виктор</td>\n",
       "      <td>23</td>\n",
       "      <td>95</td>\n",
       "      <td>104.5</td>\n",
       "      <td>A</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Галина</td>\n",
       "      <td>24</td>\n",
       "      <td>82</td>\n",
       "      <td>90.2</td>\n",
       "      <td>B</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Имя  Возраст  Баллы  Новый столбец Категория\n",
       "1   Борис       22     76           83.6         B\n",
       "2  Виктор       23     95          104.5         A\n",
       "3  Галина       24     82           90.2         B"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[df[\"Возраст\"] > 21]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "b30c8bd6-10e0-4106-a602-57f51c4eddca",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Сумма элементов массива: 15\n",
      "Среднее значение: 3.0\n",
      "Медиана: 3.0\n",
      "Стандартное отклонение: 1.4142135623730951\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "arr = np.array([1, 2, 3, 4, 5])\n",
    "print(\"Сумма элементов массива:\", np.sum(arr))\n",
    "print(\"Среднее значение:\", np.mean(arr))\n",
    "print(\"Медиана:\", np.median(arr))\n",
    "print(\"Стандартное отклонение:\", np.std(arr))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "c54b81d5-0c38-4aee-a273-5b722ad1a192",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Двумерный массив:\n",
      "[[1 2]\n",
      " [3 4]]\n",
      "Сумма всех элементов: 10\n"
     ]
    }
   ],
   "source": [
    "arr2d = np.array([[1, 2], [3, 4]])\n",
    "print(\"Двумерный массив:\")\n",
    "print(arr2d)\n",
    "print(\"Сумма всех элементов:\", np.sum(arr2d))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "69c2149c-a037-4995-9a1a-5649b59f2512",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "linspace (5 чисел от 0 до 10): [ 0.   2.5  5.   7.5 10. ]\n",
      "Случайные числа: [-0.8440093  -0.2156765   0.19534026]\n"
     ]
    }
   ],
   "source": [
    "print(\"linspace (5 чисел от 0 до 10):\", np.linspace(0, 10, 5))\n",
    "print(\"Случайные числа:\", np.random.randn(3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "8d747797-7dd4-44f7-a08b-2e91620f11c3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Скалярное произведение: 32\n"
     ]
    }
   ],
   "source": [
    "a = np.array([1, 2, 3])\n",
    "b = np.array([4, 5, 6])\n",
    "print(\"Скалярное произведение:\", np.dot(a, b))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "1740f990-b413-4c0a-aad0-df2b993d002b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 39584 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "\n",
    "x = np.linspace(0, 10, 100)\n",
    "y = np.sin(x)\n",
    "\n",
    "plt.plot(x, y, label='sin(x)')\n",
    "plt.xlabel(\"X\")\n",
    "plt.ylabel(\"Y\")\n",
    "plt.title(\"График синуса\")\n",
    "plt.legend()\n",
    "plt.grid()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "91cf5a19-17fd-4cd8-82ee-c6bfff62e7d3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 53060 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = np.linspace(0, 10, 100)\n",
    "plt.plot(x, np.sin(x), color='red', label='sin(x)')\n",
    "plt.plot(x, np.cos(x), color='blue', label='cos(x)')\n",
    "plt.xlabel(\"X\")\n",
    "plt.ylabel(\"Y\")\n",
    "plt.title(\"Графики синуса и косинуса\")\n",
    "plt.legend()\n",
    "plt.grid()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "cf28b761-dcae-4e6e-9380-3a076554b1d3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 14604 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Генерируем случайные данные\n",
    "data = np.random.randn(1000)\n",
    "plt.hist(data, bins=30, color='green', alpha=0.7)\n",
    "plt.title(\"Гистограмма\")\n",
    "plt.xlabel(\"Значение\")\n",
    "plt.ylabel(\"Частота\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "95439536-ef75-45d1-a970-959cc00f318f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 18880 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = np.random.randn(50)\n",
    "y = np.random.randn(50)\n",
    "plt.scatter(x, y, color='purple', alpha=0.6)\n",
    "plt.title(\"Точечный график\")\n",
    "plt.xlabel(\"X\")\n",
    "plt.ylabel(\"Y\")\n",
    "plt.grid()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "070585c2-c4c1-420d-9ecb-f80c0022624d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 20180 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import seaborn as sns\n",
    "\n",
    "# Используем наш DataFrame df (он уже есть из pandas-заданий)\n",
    "sns.boxplot(x=\"Категория\", y=\"Баллы\", data=df)\n",
    "plt.title(\"Boxplot баллов по категориям\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "1f7e502f-f25a-47ea-b65e-c929d2340886",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 16756 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.histplot(df[\"Баллы\"], bins=4, color='skyblue')\n",
    "plt.title(\"Распределение баллов\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "6e21d216-f873-4890-bd4b-def6fd81019f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 25932 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.scatterplot(x=\"Возраст\", y=\"Баллы\", data=df, hue=\"Категория\", s=100)\n",
    "plt.title(\"Зависимость баллов от возраста\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "4c214bb0-6128-4db0-a2a0-ca8ff33359df",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 81784 characters]",
      "text/plain": [
       "<Figure size 838.236x750 with 12 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Создадим расширенный DataFrame для pairplot\n",
    "df_more = pd.DataFrame({\n",
    "    \"Возраст\": [21, 22, 23, 24, 25, 26, 27, 28],\n",
    "    \"Баллы\": [89, 76, 95, 82, 88, 91, 79, 85],\n",
    "    \"Время\": [30, 45, 35, 50, 40, 35, 45, 40],\n",
    "    \"Категория\": [\"A\", \"B\", \"A\", \"B\", \"A\", \"B\", \"A\", \"B\"]\n",
    "})\n",
    "\n",
    "sns.pairplot(df_more, hue=\"Категория\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "3ce55593-530e-4cc8-9d63-2912491bbe69",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Загрузка: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 93.74it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Готово!\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "from tqdm import tqdm\n",
    "import time\n",
    "\n",
    "for i in tqdm(range(100), desc=\"Загрузка\"):\n",
    "    time.sleep(0.01)\n",
    "print(\"Готово!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "d82f0a8c-98de-4453-a4ef-82cf82e0d766",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   total_bill   tip     sex smoker  day    time  size\n",
      "0       16.99  1.01  Female     No  Sun  Dinner     2\n",
      "1       10.34  1.66    Male     No  Sun  Dinner     3\n",
      "2       21.01  3.50    Male     No  Sun  Dinner     3\n",
      "3       23.68  3.31    Male     No  Sun  Dinner     2\n",
      "4       24.59  3.61  Female     No  Sun  Dinner     4\n",
      "<class 'pandas.DataFrame'>\n",
      "RangeIndex: 244 entries, 0 to 243\n",
      "Data columns (total 7 columns):\n",
      " #   Column      Non-Null Count  Dtype   \n",
      "---  ------      --------------  -----   \n",
      " 0   total_bill  244 non-null    float64 \n",
      " 1   tip         244 non-null    float64 \n",
      " 2   sex         244 non-null    category\n",
      " 3   smoker      244 non-null    category\n",
      " 4   day         244 non-null    category\n",
      " 5   time        244 non-null    category\n",
      " 6   size        244 non-null    int64   \n",
      "dtypes: category(4), float64(2), int64(1)\n",
      "memory usage: 7.4 KB\n",
      "None\n"
     ]
    }
   ],
   "source": [
    "# Загружаем встроенный датасет 'tips' (чаевые в ресторане)\n",
    "df_real = sns.load_dataset('tips')\n",
    "print(df_real.head())\n",
    "print(df_real.info())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "e4601219-6416-46c6-be5a-80d92e5b4be2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Информация о данных:\n",
      "<class 'pandas.DataFrame'>\n",
      "RangeIndex: 244 entries, 0 to 243\n",
      "Data columns (total 7 columns):\n",
      " #   Column      Non-Null Count  Dtype   \n",
      "---  ------      --------------  -----   \n",
      " 0   total_bill  244 non-null    float64 \n",
      " 1   tip         244 non-null    float64 \n",
      " 2   sex         244 non-null    category\n",
      " 3   smoker      244 non-null    category\n",
      " 4   day         244 non-null    category\n",
      " 5   time        244 non-null    category\n",
      " 6   size        244 non-null    int64   \n",
      "dtypes: category(4), float64(2), int64(1)\n",
      "memory usage: 7.4 KB\n",
      "None\n",
      "\n",
      "Статистика:\n",
      "       total_bill         tip        size\n",
      "count  244.000000  244.000000  244.000000\n",
      "mean    19.785943    2.998279    2.569672\n",
      "std      8.902412    1.383638    0.951100\n",
      "min      3.070000    1.000000    1.000000\n",
      "25%     13.347500    2.000000    2.000000\n",
      "50%     17.795000    2.900000    2.000000\n",
      "75%     24.127500    3.562500    3.000000\n",
      "max     50.810000   10.000000    6.000000\n",
      "\n",
      "Проверка пропусков:\n",
      "total_bill    0\n",
      "tip           0\n",
      "sex           0\n",
      "smoker        0\n",
      "day           0\n",
      "time          0\n",
      "size          0\n",
      "dtype: int64\n"
     ]
    }
   ],
   "source": [
    "print(\"Информация о данных:\")\n",
    "print(df_real.info())\n",
    "print(\"\\nСтатистика:\")\n",
    "print(df_real.describe())\n",
    "print(\"\\nПроверка пропусков:\")\n",
    "print(df_real.isnull().sum())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "63ffce9e-4e45-4481-92a7-0d93d4f5331e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 17652 characters]",
      "text/plain": [
       "<Figure size 800x400 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(8,4))\n",
    "sns.histplot(df_real['total_bill'], bins=20, color='green')\n",
    "plt.title('Распределение общего счета')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "36a7f627-7eb5-45d2-a783-e81dbcd150fd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 54680 characters]",
      "text/plain": [
       "<Figure size 800x400 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(8,4))\n",
    "sns.scatterplot(x='total_bill', y='tip', data=df_real, hue='time')\n",
    "plt.title('Зависимость чаевых от суммы счета')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "329d9fca-a54e-4a20-8626-eda614619d03",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 18316 characters]",
      "text/plain": [
       "<Figure size 800x400 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure(figsize=(8,4))\n",
    "sns.boxplot(x='day', y='total_bill', data=df_real)\n",
    "plt.title('Сумма счета по дням недели')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "78081377-bd29-4897-aaf9-4bd110b05aa9",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.14.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
