240 lines
208 KiB
Plaintext
240 lines
208 KiB
Plaintext
|
{
|
|||
|
"cells": [
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## Начало лабораторной работы.\n",
|
|||
|
"Выгрузка данных их csv-файла в датафрейм:"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 7,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [],
|
|||
|
"source": [
|
|||
|
"from typing import Any\n",
|
|||
|
"\n",
|
|||
|
"import pandas as pd\n",
|
|||
|
"from pandas import DataFrame, Series\n",
|
|||
|
"import matplotlib.pyplot as plt\n",
|
|||
|
"\n",
|
|||
|
"\n",
|
|||
|
"df: DataFrame = pd.read_csv('..//static//csv//TSLA.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: 156 entries, 0 to 155\n",
|
|||
|
"Data columns (total 9 columns):\n",
|
|||
|
" # Column Non-Null Count Dtype \n",
|
|||
|
"--- ------ -------------- ----- \n",
|
|||
|
" 0 Insider Trading 156 non-null object \n",
|
|||
|
" 1 Relationship 156 non-null object \n",
|
|||
|
" 2 Date 156 non-null object \n",
|
|||
|
" 3 Transaction 156 non-null object \n",
|
|||
|
" 4 Cost 156 non-null float64\n",
|
|||
|
" 5 Shares 156 non-null object \n",
|
|||
|
" 6 Value ($) 156 non-null object \n",
|
|||
|
" 7 Shares Total 156 non-null object \n",
|
|||
|
" 8 SEC Form 4 156 non-null object \n",
|
|||
|
"dtypes: float64(1), object(8)\n",
|
|||
|
"memory usage: 11.1+ KB\n",
|
|||
|
" count mean std min 25% 50% 75% max\n",
|
|||
|
"Cost 156.0 478.785641 448.922903 0.0 50.5225 240.225 934.1075 1171.04\n"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"df.info()\n",
|
|||
|
"print(df.describe().transpose())"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## График 1.\n",
|
|||
|
"\n",
|
|||
|
"### Круговая диаграмма.\n",
|
|||
|
"\n",
|
|||
|
"Данная круговая диаграмма отображает распределение количества сделок, совершенных инсайдерами. Это позволяет сделать вывод о том, какие инсайдеры были наиболее активны в торговле акциями, давая возможность быстро оценить лидеров по количеству транзакций, коим в данном случае является CEO компании — Илон Маск."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 10,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAzMAAAKSCAYAAADmnIVJAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAADakElEQVR4nOzdd1gUVxcH4N/u0ntvShUQVMRYIxoVS1AsURONEaPYUmyxxZKoYCyx997AxN6NXVFQVFQsoEZURIog0jtsn+8PPjasdAQGlvM+D4/u7J17z8zWs7cMh2EYBoQQQgghhBDSwHDZDoAQQgghhBBCqoOSGUIIIYQQQkiDRMkMIYQQQgghpEGiZIYQQgghhBDSIFEyQwghhBBCCGmQKJkhhBBCCCGENEiUzBBCCCGEEEIaJEpmCCGEEEIIIQ0SJTO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JAYAEx4ezjAMw4SFhTEAmAkTJsiVmz17NgOAuXHjhmzbx+edYQofcw0NjRLHQwghDMMwNMyslvTu3RvGxsawtLTEiBEjoKWlhdOnT6NJkyYACn9Z5HILT79EIkFaWhq0tLTQvHlzPH78WFbPyZMnYWRkhKlTp5Zoo7RhK5U1evRoaGtry25/8803MDc3x8WLFwEAYWFhiIyMxMiRI5GWlobU1FSkpqYiLy8PvXr1wq1bt0oMG+Lz+VBTUyu33VOnTkEqlWL48OGyOlNTU2FmZgYHBwcEBgbKlRcKhQAKz1dZjh8/Dl1dXfTp00euznbt2kFLS6tEnSKRSK5campqiSERH0tISMDmzZu
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 800x800 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"# Подсчет количества сделок для каждого инсайдера\n",
|
|||
|
"insider_count: Series[int] = df['Insider Trading'].value_counts()\n",
|
|||
|
"\n",
|
|||
|
"# Получение цветовой схемы\n",
|
|||
|
"colors = plt.get_cmap('tab10')(range(len(insider_count)))\n",
|
|||
|
"\n",
|
|||
|
"# Визуализация в виде круговой диаграммы\n",
|
|||
|
"plt.figure(figsize=(8, 8))\n",
|
|||
|
"insider_count.plot(kind='pie', autopct='%1.1f%%', startangle=90, colors=colors, labels=['']*len(insider_count))\n",
|
|||
|
"\n",
|
|||
|
"# Добавление легенды\n",
|
|||
|
"plt.legend(labels=insider_count.index, loc='upper right', bbox_to_anchor=(1.3, 1))\n",
|
|||
|
"plt.title('Распределение количества сделок среди инсайдеров')\n",
|
|||
|
"plt.ylabel('')\n",
|
|||
|
"plt.axis('equal')\n",
|
|||
|
"\n",
|
|||
|
"# Отображение графика\n",
|
|||
|
"plt.show()"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## График 2.\n",
|
|||
|
"\n",
|
|||
|
"### Столбчатая диаграмма.\n",
|
|||
|
"\n",
|
|||
|
"Диаграмма показывает сколько сделок каждого типа было совершено инсайдерами. Для каждого инсайдера отдельный столбец, где каждый цвет представляет один тип сделки. На основе полученного графика можно сделать вывод, что основную часть сделок составляют продажи акций, а не опционов."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 11,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA90AAAJOCAYAAACqS2TfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAADNzklEQVR4nOzdd3gU1dvG8XsDIZBOrwFC770jvUtvKoJUBRGkCQoqHaRXRYoFsGBBVIp0BKRLR6T3EppAElpCkj3vH7zZX5aEACHLJuH7ua5csGdmZ56dPTOzz8w5ZyzGGCMAAAAAABDvXJwdAAAAAAAASRVJNwAAAAAADkLSDQAAAACAg5B0AwAAAADgICTdAAAAAAA4CEk3AAAAAAAOQtINAAAAAICDkHQDAAAAAOAgJN0AAAAAADgISTcAAAASlE8++URWq1WSZLVaNWbMGCdHBABxR9INIMGbN2+eLBaLdu3aFW3aF198IYvFombNmikiIsIJ0QEA4tv8+fM1ceJEXbhwQZMmTdL8+fOdHRIAxFlyZwcAAHH122+/qXv37qpSpYp+/PFHJUuWzNkhAQDiwYgRI9S+fXt98MEHcnNz03fffefskAAgzki6ASRKGzZsUJs2bVSoUCEtXbpUKVOmdHZIAIB48uqrr6pGjRo6ceKE8ubNq/Tp0zs7JACIM5qXA0h09u3bp6ZNmypz5sxatWqVfHx8os2zcOFClS5dWqlSpVK6dOnUrl07Xbx4McblWSyWGP/OnDljN8+wYcPs3jdhwgRZLBZVr17dVjZs2DBZLJZo68iZM6c6duxoVxYYGKg+ffrIz89Pbm5uypMnj8aNG2frxxjJarVq2rRpKlq0qFKmTKn06dOrfv36tub2j4o/8i8yvg0bNtiVu7m5KV++fBozZoyMMXbr3Lt3rxo0aCBvb295enqqVq1a2r59e4zb72GPizfSw/FE/XvYxYsX1blzZ2XMmFFubm4qXLiwvv766xjX37FjxxiX+fD39+eff6pKlSry8PCQr6+vmjZtqsOHD9vNE9P3uX79erm5uentt9+OdTtEfr4NGzbYygICApQzZ06VKVNGt2/fliTdv39fQ4YMUenSpeXj4yMPDw9VqVJF69evt1venj175OHhoZ49e9qVP1y37t27p3LlyqlQoUIKDAy0mzeyq8bDfzlz5owW/9Nsn4f/kie3v6b/NPvj42KN+jdv3jxJD77zhz/D+fPnlSpVqmj7cs6cOWNdZlRz585VzZo1lSFDBrm5ualQoUKaOXNmrHE/7FHri4w9qkdtz4ePHevXr1eVKlWUOnVqu/kerhsPi6lOSlLDhg2j7SORsfz333928+7atSvG+I8cOaJXXnlF6dOnV6pUqZQ/f3599NFHtulnz57VO++8o/z58ytVqlRKmzatWrdubffdSP/73s+cOaMMGTKoUqVKSps2rYoVK/bI7fak29hqtWrq1KkqXLiwUqZMqYwZM6pbt266efNmtOU1atRIq1evVokSJZQyZUoVKlRIv/76a7R1nzp1Sq1bt1aaNGnk7u6uChUq6I8//ohxuz/JsRdA0sSdbgCJysmTJ1W/fn25ublp1apVypw5c7R55s2bp06dOqls2bIaM2aMrly5omnTpmnLli3au3evfH19o72nefPmatGihSRp06ZNmjNnTqxxBAYGPtPAPnfv3lW1atV08eJFdevWTdmzZ9fWrVs1aNAgXbp0SVOnTrXN26VLF82bN08NGjTQm2++qfDwcG3atEnbt29XmTJl9O2339rmjYx9ypQpSpcunSQpY8aMduv+8MMPVbBgQd27d08//fSTPvzwQ2XIkEFdunSRJP3777+qUqWKvL299f7778vV1VWzZ89W9erVtXHjRpUvXz7Wz/a4eB/Wq1cvlS1bVpL0zTffaM2a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wxmTNnNi+99JJd3XqUqNs7JCTEVK9e3WTIkMGcOHHCbr7w8HATGhpqV3bz5k2TMWNG07lz52jLHT9+vEmWLJlZuXKlMca+bn344YfGzc3NbN68OcaY5syZYySZXbt22coaNmxocuTIYTff026fa9euxbi+p90fY1OtWjW7fS2qDh062H2GgwcPGhcXF9OgQYNo+0OOHDlMw4YNoy0jprr3cN0yxph69eqZXLlyPXHcWbJkMY0aNbK93rlzp5Fk5s6dG23ejz76yFgsFruyh48ds2fPNpLMtm3b7OaTZHr06BFrLDEdA8qXL2/bTlH3kUd9tzHFX7VqVePl5WXOnj1rN2/UfT6mbblt2zYjyXzzzTe2soePYSEhISZ79uy2GGPabk+yjTdt2mQkme+//97uvStXroxWniNHDiPJLFq0yFYWFBRkMmfObEqWLGkr69Onj5FkNm3aZCu7deuW8ff3Nzlz5jQRERHGmCc/9gJIumheDiDR6Nixo86fP6/XX39dq1ev1sKFC6PNs2vXLl29elXvvPOOXT/vhg0bqkCBAtGa/d2/f1+S5Obm9sRxXLx4UZ9++qkGDx5sd3dPkjJkyCBJunDhQqzLWLhwoa156H///Wf7q127tiIiIvTXX39JkhYtWiSLxaKhQ4dGW0ZMzbCfRFBQkP777z+dO3dO48ePl9VqVc2aNSVJERERWr16tZo1a6ZcuXLZ3pM5c2a9/vrr2rx5s4KDgx+57KeJN/IuZGz98Y0xWrRokRo3bixjjN22qlevnoKCgrRnzx6799y/fz/W7/PSpUvat2+fOnbsqDRp0tjKixUrpjp16sR41+/69euqV6+evLy8tGTJkqcaQ8Bqtap9+/bavn27li9frty5c9tNT5YsmVKkSGGb98aNGwoPD1eZMmWifTZJGjBggN544w298sorOnTokK3822+/1SeffKLZs2ercuXKMcbyJNs8LtvnUZ52f4wvgwYNUqlSpdS6detnWk6qVKls/4/cb6pVq6ZTp04pKCjoiZYREhL
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 1000x600 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"# Подсчет количества сделок каждого типа (Transaction) для каждого инсайдера\n",
|
|||
|
"transaction_count: DataFrame | Series[Any] = df.groupby(['Insider Trading', 'Transaction']).size().unstack(fill_value=0)\n",
|
|||
|
"\n",
|
|||
|
"# Визуализация в виде столбчатой диаграммы\n",
|
|||
|
"transaction_count[['Sale', 'Option Exercise']].plot(kind='bar', stacked=True, figsize=(10, 6), color=['skyblue', 'lightgreen'])\n",
|
|||
|
"\n",
|
|||
|
"# Добавление легенды\n",
|
|||
|
"plt.title('Количество сделок каждого типа для инсайдеров')\n",
|
|||
|
"plt.xlabel('Инсайдер')\n",
|
|||
|
"plt.ylabel('Количество сделок')\n",
|
|||
|
"plt.xticks(rotation=45, ha='right')\n",
|
|||
|
"plt.legend(title='Тип сделки')\n",
|
|||
|
"plt.grid(True)\n",
|
|||
|
"\n",
|
|||
|
"# Отображение графика\n",
|
|||
|
"plt.tight_layout()\n",
|
|||
|
"plt.show()"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"## График 3.\n",
|
|||
|
"\n",
|
|||
|
"### Линейная диаграмма.\n",
|
|||
|
"\n",
|
|||
|
"Данная линейная диаграмма отображает количество сделок, совершённых инсайдерами, в разрезе по месяцам. Это помогает выявить периоды с наибольшей активностью инсайдеров или сезонные колебания на рынке. На графике видно, что продажи акций летом постепенно уменьшались и почти достигли своего минимума в конце сезона, после чего начался рост."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 18,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABKUAAAJOCAYAAABm7rQwAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAACtYklEQVR4nOzdd3hUZfrG8e+kE1KogQChg4B0REGkd5CODezYUVB3dXV3LazrYll/ir2sqyiiLgiCSu8goNKLgPQk9JaEENLP7483CcYECMPMnJnJ/bmuuebMmZkzd5JhmHnmfZ/XYVmWhYiIiIiIiIiIiAcF2B1ARERERERERERKHxWlRERERERERETE41SUEhERERERERERj1NRSkREREREREREPE5FKRERERERERER8TgVpURERERERERExONUlBIREREREREREY9TUUpERERERERERDxORSkREREREREREfE4FaVERERERERERMTjVJQSERERERERERGPU1FKRETEJp9++ikOh4M1a9YUue6jjz7C4XAwePBgcnJybEgnIiIiIuJeKkqJiIh4menTp/Pggw/SsWNHvvrqKwIDA+2OJCIiIiLicipKiYiIeJElS5Zwyy230KRJE7777jvCwsLsjiQiIiIi4hYqSomIiHiJDRs2MGjQIGJjY5k7dy7R0dFFbjNlyhTatGlDmTJlqFSpErfeeisHDhwo9ngOh6PY0759+wrd5vnnny90v1dffRWHw0GXLl0K9j3//PM4HI4ij1G7dm3uvPPOQvuSkpJ49NFHiYuLIzQ0lPr16/Pyyy+Tm5tb6Ha5ublMmDCBZs2aERYWRuXKlenTp0/BdMbz5c8/5edbsmRJof2hoaE0bNiQ8ePHY1lWocdcv349ffv2JSoqioiICLp3787q1auL/f390cXy5vtjnt+f/ujAgQPcfffdVKlShdDQUK688kr++9//Fvv4d955Z7HH/OPfb9GiRXTs2JGyZctSrlw5Bg0axLZt2wrdpri/5+LFiwkNDeWBBx644O/hQj+fw+Eo8nzYs2cPN9xwAxUqVCA8PJx27drxww8/XPAx8uUf84033ihyXaNGjXA4HDz88MOF9rvq+QeQmprKn/70J+rWrUtwcHChn/P48eOFcv4xB8D1119P7dq1C+3btGkTd955J3Xr1iUsLIyqVaty9913c+LEiUK3y/8bxcTEkJWVVei6L7/8stgcIiIivibI7gAiIiICu3fvpk+fPoSGhjJ37lxiY2OL3ObTTz/lrrvuom3btowfP54jR44wYcIEfvzxR9avX0+5cuWK3GfIkCEMHToUgOXLl/Phhx9eMEdSUhLjx493+udIS0ujc+fOHDhwgPvvv5+aNWuycuVKnn76aQ4dOlSouDBq1Cg+/fRT+vbtyz333EN2djbLly9n9erVXHXVVXz++ecFt83P/vrrr1OpUiUAqlSpUuix//rXv9K4cWPOnj3L119/zV//+ldiYmIYNWoUAFu3bqVjx45ERUXx5JNPEhwczAcffECXLl1YunQp11xzzQV/tovl/aMxY8bQtm1bAD777DPmz59f6PojR47Qrl27goJG5cqVmT17NqNGjSIlJYVHH320yDErVarE66+/XnD5tttuK3T9ggUL6Nu3L3Xr1uX555/n7NmzvPXWW3To0IF169YVKZDk27hxI4MHD6Zfv3688847F/w9FPfz5bvnnnuK/IzXXnstaWlpjBkzhooVKzJx4kQGDhzI1KlTGTJkyEUfJywsjE8++aTQ72PlypXs37+/yG1d+fwDeOKJJ3j//fcZNWoUHTp0IDg4mGnTpjF9+vQS/Y6KM3/+fPbs2cNdd91F1apV2bp1Kx9++CFbt25l9erVRYqFp0+f5vvvvy/0u/rkk08ICwsjPT3d6RwiIiJewRIRERFbfPLJJxZgff/991a9evUswOrVq1ext83MzLRiYmKspk2bWmfPni3Y//3331uA9eyzzxa6fVZWlgVY48aNK/J4e/fuLdgHWM8991zB5SeffNKKiYmx2rRpY3Xu3Llg/7hx4yzAys3NLfQ4tWrVsu64446Cyy+88IJVtmxZ67fffit0u6eeesoKDAy04uPjLcuyrEWLFlmANWbMmCI/6x8f43zZ8y1evNgCrMWLFxfsS09PtwICAqyHHnqoYN/gwYOtkJAQa/fu3QX7Dh48aEVGRlqdOnUqctzfu5S88+bNswBr6tSpBftGjx5t/fFt16hRo6zY2Fjr+PHjhfbffPPNVnR0tJWWllZo/8iRI606deoU2vfHv1/Lli2tmJgY68SJEwX7Nm7caAUEBFi33357wb7nnnuuIM++ffus2NhY67rrriv03Dqf/N/3lClTilxXtmzZQs+HRx991AKs5cu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YsVapUoUyZMlSuXJk6deoAFPl3D9CyZUuaNm3KZ599hmVZBdN4RURE/IF6SomIiNjs1Vdf5YYbbgDgww8/pF27djz99NO8++67Th8zf1RF1apVS3T7bdu28emnnzJp0iSCg4OLXN+iRQuee+45xo0bxxdffHHe4+Tm5tKzZ0+efPLJYq935+iOf//737Ro0YKsrCx++eUX/vnPfxIUFFTsaBh3ym8kf77+TUBBMe/WW2/ljjvuKPY2zZs3L3T58OHD1KpVyyUZ823fvp3Zs2dz44038qc//algNJK36d+/PyEhIXz77bd88skn3HHHHQQEFP1u1dXPvw8//JBbbrml4N+nK9x4442sXLmSJ554gpYtWxIREUFubi59+vQpUuTNd/fdd/Puu+9y9dVXc/jwYW688UZee+01l2USERGxi4pSIiIiNuvUqVPBdtu2bRk9ejTvvPMOt99+e8G0nvxixI4dO4qMENmxY0eRYkX+tKj8ESkX8/TTT9OyZUtuuumm897mueee47777mP79u3k5OQApqjye/Xq1SM1NbVgZMr51KtXj7lz53L
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 1200x600 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"# Преобразование колонки 'Date' в datetime формат\n",
|
|||
|
"df['Date'] = pd.to_datetime(df['Date'])\n",
|
|||
|
"\n",
|
|||
|
"# Создание новой колонки с месяцами\n",
|
|||
|
"df['Month'] = df['Date'].dt.to_period('M')\n",
|
|||
|
"\n",
|
|||
|
"# Подсчет количества сделок по месяцам\n",
|
|||
|
"monthly_transactions: DataFrame | Series[int] = df.groupby('Month').size()\n",
|
|||
|
"\n",
|
|||
|
"# Визуализация в виде линейной диаграммы\n",
|
|||
|
"plt.figure(figsize=(12, 6))\n",
|
|||
|
"monthly_transactions.plot(kind='line', marker='o', color='darkorange')\n",
|
|||
|
"\n",
|
|||
|
"# Добавление легенды\n",
|
|||
|
"plt.title('Количество сделок по месяцам')\n",
|
|||
|
"plt.xlabel('Месяц')\n",
|
|||
|
"plt.ylabel('Количество сделок')\n",
|
|||
|
"plt.grid(True)\n",
|
|||
|
"plt.xticks(rotation=45)\n",
|
|||
|
"\n",
|
|||
|
"# Отображение графика\n",
|
|||
|
"plt.tight_layout()\n",
|
|||
|
"plt.show()"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"metadata": {
|
|||
|
"kernelspec": {
|
|||
|
"display_name": "aimenv",
|
|||
|
"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.5"
|
|||
|
}
|
|||
|
},
|
|||
|
"nbformat": 4,
|
|||
|
"nbformat_minor": 2
|
|||
|
}
|