AIM-PIbd-31-Medvedkov-A-D/Lab_1/lab1.ipynb

250 lines
130 KiB
Plaintext
Raw Normal View History

2024-09-27 00:19:23 +04:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Импорт библиотек и загрузка датасета"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"<>:4: SyntaxWarning: invalid escape sequence '\\j'\n",
"<>:4: SyntaxWarning: invalid escape sequence '\\j'\n",
"C:\\Users\\MaD\\AppData\\Local\\Temp\\ipykernel_9800\\3091210825.py:4: SyntaxWarning: invalid escape sequence '\\j'\n",
" df = pd.read_csv(\"data\\jio_mart_items.csv\")\n"
]
}
],
"source": [
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"\n",
"df = pd.read_csv(\"data\\jio_mart_items.csv\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Изучение полученных данных"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"RangeIndex: 162313 entries, 0 to 162312\n",
"Data columns (total 5 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 category 162313 non-null object \n",
" 1 sub_category 162313 non-null object \n",
" 2 href 162313 non-null object \n",
" 3 items 162280 non-null object \n",
" 4 price 162282 non-null float64\n",
"dtypes: float64(1), object(4)\n",
"memory usage: 6.2+ MB\n"
]
}
],
"source": [
"df.info()\n",
"\n",
"# print(df.describe().transpose())\n",
"\n",
"# cleared_df = df.drop([\"Name\", \"Ticket\", \"Embarked\"], axis=1)\n",
"# print(cleared_df.head())\n",
"# print(cleared_df.tail())\n",
"\n",
"# sorted_df = cleared_df.sort_values(by=\"Age\")\n",
"# print(sorted_df.head())\n",
"# print(sorted_df.tail())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Захотел посмотреть кол-во подкатегорий."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"72\n"
]
}
],
"source": [
"print(len(set(df[\"sub_category\"])))\n",
"\n",
"# print(df.sort_values(by=\"category\")[[\"category\", \"sub_category\"]])\n",
"\n",
"# print(df.loc[100])\n",
"\n",
"# print(df.loc[100, \"Name\"])\n",
"\n",
"# print(df.loc[100:200, [\"Age\", \"Name\"]])\n",
"\n",
"# print(df[0:3])\n",
"\n",
"# print(df.iloc[0])\n",
"\n",
"# print(df.iloc[3:5, 0:2])\n",
"\n",
"# print(df.iloc[[3, 4], [0, 1]])"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA90AAAJOCAYAAACqS2TfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAABfbklEQVR4nO3deXwNZ///8fdJZBMSexbSoFpiKUpvIrZWiK1otepGRauqSku1lC6WLndUSy21VLW0qnfVeiutfStS+1ZLLI3SkqBIaktIrt8fvpmfI0FCppH09Xw8zkPmmmvmfOacyznnfWbOjMMYYwQAAAAAALKdS04XAAAAAABAXkXoBgAAAADAJoRuAAAAAABsQugGAAAAAMAmhG4AAAAAAGxC6AYAAAAAwCaEbgAAAAAAbELoBgAAAADAJoRuAAAAAABsQugGAAAAAMAmhG4AwN/i0KFD6t69u8qWLStPT0/5+PgoLCxMo0eP1sWLF3O6PAAAAFvky+kCAAB538KFC/Xkk0/Kw8NDnTt3VuXKlZWcnKy1a9eqX79+2r17tyZNmpTTZQIAAGQ7hzHG5HQRAIC8KzY2Vg888IBKlSqlFStWKCAgwGn+wYMHtXDhQvXu3TuHKgQAALAPh5cDAGw1fPhwnTt3Tp9//nm6wC1J5cqVcwrcD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/559/Xu7u7po8ebLCw8NVsWLFO+p3J9q1a6c//vgj3V566eph1efPn8/
"text/plain": [
"<Figure size 1000x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"\n",
"avg_price_by_category = df.groupby('category')['price'].mean()\n",
"\n",
"plt.figure(figsize=(10, 6))\n",
"avg_price_by_category.plot(kind='bar', color='skyblue')\n",
"plt.title('Средняя цена по категории')\n",
"plt.xlabel('Категория')\n",
"plt.ylabel('Средняя цена')\n",
"plt.xticks(rotation=0)\n",
"plt.tight_layout()\n",
"plt.show()\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Данная диаграмма отображает среднюю цену по категории и иллюстрирует очевидный факт: электроника и ювелирные украшения стоят больше всего."
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAw0AAAL6CAYAAAB0Abr1AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAACwhUlEQVR4nOzdd3wT9f8H8NclbdN070lpgbL3cEAFioJMRUFAVIaC6E8R8StuEXGBe6IsBQEHQ1yAgOwpu6wW6N57N20z7/dHbSS0lLa0vYzX8/HoA3q53L0vTdO88lmCKIoiiIiIiIiIrkMmdQFERERERGTeGBqIiIiIiKhODA1ERERERFQnhgYiIiIiIqoTQwMREREREdWJoYGIiIiIiOrE0EBERERERHViaCAiIiIiojoxNBARERERUZ0YGoiIiBqgrKwMn332mfH7oqIiLFmyRLqCiIhaAEMDUTNbvXo1BEEwfjk6OqJDhw6YPXs2srOzpS6PiBpIqVTi9ddfxw8//IDU1FS8+eab+PPPP6Uui4ioWdlJXQCRrXjrrbfQpk0bVFZW4tChQ/jmm2+wbds2XLhwAU5OTlKXR0T1JJfLsXDhQkydOhUGgwFubm7YunWr1GURETUrhgaiFjJy5Ej069cPADBz5kx4e3vjk08+we+//47JkydLXB0RNcTzzz+PSZMmITU1FZ07d4aHh4fUJRERNSt2TyKSyJ133gkASExMBAAUFBRg3rx56N69O1xcXODm5oaRI0fi7NmzNe5bWVmJN998Ex06dICjoyMCAwMxbtw4xMfHAwCSkpJMukRd+xUZGWk81r59+yAIAtavX49XX30VAQEBcHZ2xr333ovU1NQa5964cSP69u0LpVIJHx8fPPLII0hPT6+x36VLlzBx4kT4+vpCqVSiY8eOeO211wAAb775Zp31CYKAffv2AQAiIyPRrVs3nDp1CgMGDIBSqUSbNm2wdOlSk/NpNBq88cYb6Nu3L9zd3eHs7IyBAwdi7969JvtVPzYfffRRjZq7detm8tgAgFqtxoIFCxAeHg6FQoGQkBC8+OKLUKvVJvsJgoDZs2fXOOaYMWMQFhbW6PPn5ORgxowZ8Pf3h6OjI3r27Invv/++xn0NBgM+//xzdO/eHY6OjvD19cWIESNw8uRJY331eU5UPx82bdpU4xw3Un3f6p8dAGRkZCAsLAz9+vVDWVkZgPr/rE6fPg1nZ+caj2tYWBimT59u/L6iogK33norunTpgqKiIpN9r+0eWP119c+k2p49ezBw4EA4OzvDw8MDY8eORUxMjMk+1c9dAGjVqhX69+8POzs7BAQE1Lj22lx9/2p79+6FQqHAk08+adyWnJyMp556Ch07doRSqYS3tzcmTJiApKSkG17b1V+rV6827n/p0iU88MAD8PLygqOjI/r164c//vijXo+XIAhIS0tr1GNV/Vrg5uYGb29vPPvss6isrDTZVxAEvPnmmybbPvzww+u+Xl37OI8ePbrWYxBR02FLA5FEqt/ge3t7AwASEhLw22+/YcKECWjTpg2ys7OxbNkyDB48GNHR0QgKCgIA6PV6jBkzBrt378aDDz6IZ599FqWlpfj7779x4cIFtGvXzniOyZMnY9SoUSbnfeWVV2qt591334UgCHjppZeQk5ODzz77DEOHDkVUVBSUSiWAqjcUjz76KG655RYsWrQI2dnZ+Pzzz3H48GGcOXPG+GnruXPnMHDgQNjb22P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XdP2Lmzfvr3J94IgIDw83NiHOjk5GQDQsWPHGvft1KmT8faEhAQAVf3zm0pQUBCcnZ1NtnXo0AEATPp4f//99+jRowccHR3h7e0NX19
"text/plain": [
"<Figure size 800x800 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"category_counts = df['category'].value_counts()\n",
"\n",
"plt.figure(figsize=(8, 8))\n",
"plt.pie(category_counts, labels=category_counts.index, autopct='%1.1f%%', colors=plt.cm.Paired.colors)\n",
"plt.title('Распространенность каждой категории')\n",
"plt.tight_layout()\n",
"plt.show()\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Данная диаграмма отображает распространённость каждой категории"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA90AAAJOCAYAAACqS2TfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAABiCElEQVR4nO3dd3gUVf/+8XsTUkmBUAPGEHroUqREekdKAEUFpYsiSFNQ/Ko0NYKCFAEVfUABFUGa4kMn9CJNBCI1SO+EUCRAcn5/8Ms+LEkgCxlC4vt1XXuROVP2szuHTe6dmTM2Y4wRAAAAAABIcy7pXQAAAAAAAJkVoRsAAAAAAIsQugEAAAAAsAihGwAAAAAAixC6AQAAAACwCKEbAAAAAACLELoBAAAAALAIoRsAAAAAAIsQugEAAAAAsAihGwAApJmPPvpICQkJkqSEhARFRESkc0WZx9GjRzVlyhT79KFDhzR9+vT0KwgAkCqEbgCZ1pQpU2Sz2bR58+Yk8yZNmiSbzabw8HDFx8enQ3VA5vTtt9/q008/1dGjRzVy5Eh9++236V1SpmGz2dSjRw8tWrRIhw4d0oABA7R69er0LgsAcA9Z0rsAAHjY5syZo+7du6t69er68ccf5erqmt4lAZnG0KF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VAkJCTpy5IhKliz5wHX8/fffKlKkSJI/ihNPZ03cl4nOnj0rSakaNO/KlStq2LChTp06pRw5ciT7BcX58+c1ZMg
"text/plain": [
"<Figure size 1000x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"subcategories_by_category = df.groupby('category')['sub_category'].nunique()\n",
"\n",
"plt.figure(figsize=(10, 6))\n",
"subcategories_by_category.plot(kind='bar', color='lightgreen')\n",
"plt.title('Количество подкатегорий в каждой категории')\n",
"plt.xlabel('Категория')\n",
"plt.ylabel('Количество подкатегорий')\n",
"plt.xticks(rotation=0)\n",
"plt.tight_layout()\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Данная диаграмма отображет количество подкатегорий в категории."
]
}
],
"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.12.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}