X-Git-Url: https://apps.delaporte.us/gitweb/dotfiles.git/blobdiff_plain/7c1afefe42dcafe9caf31207b4e54a8032553a94..9cad6021b47e3b4d285c08a4f2e57cfd7b23cef0:/data/issues.ipynb?ds=sidebyside diff --git a/data/issues.ipynb b/data/issues.ipynb index 2156a71..3340aaf 100644 --- a/data/issues.ipynb +++ b/data/issues.ipynb @@ -2,7 +2,25 @@ "cells": [ { "cell_type": "code", - "execution_count": 21, + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3.12.2\n" + ] + } + ], + "source": [ + "import platform\n", + "print(platform.python_version())" + ] + }, + { + "cell_type": "code", + "execution_count": 92, "metadata": {}, "outputs": [], "source": [ @@ -10,7 +28,119 @@ "import glob\n", "import os\n", "\n", - "data_files = glob.glob(os.path.expanduser('~\\\\Data\\\\*.json'))" + "data_files = glob.glob(os.path.expanduser('~\\\\Data\\\\*.json'))\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "\n", + "for file in data_files:\n", + "\tprint(f\"{file}\", os.path.getsize(file))\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "\n", + "data_sets = []\n", + "\n", + "file = data_files[6]\n", + "print(file)\n", + "\n", + "f = open(file, encoding='utf-8')\n", + "df = pd.read_json(f)" + ] + }, + { + "cell_type": "code", + "execution_count": 94, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "df['count'] = np.zeros(len(df))\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 95, + "metadata": {}, + "outputs": [], + "source": [ + "closed_months = pd.to_datetime(df['closedAt'], format='ISO8601')\n", + "df['closed_month'] = closed_months.dt.month" + ] + }, + { + "cell_type": "code", + "execution_count": 97, + "metadata": {}, + "outputs": [], + "source": [ + "df['mile'] = [d.get('title') if d else None for d in df.milestone]" + ] + }, + { + "cell_type": "code", + "execution_count": 98, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "grp_df = df.groupby(['mile', 'closed_month']).count().reset_index()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(grp_df)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Plot of closed issues by month and milestone for one project\n" + ] + }, + { + "cell_type": "code", + "execution_count": 99, + "metadata": {}, + "outputs": [], + "source": [ + "import seaborn as sns\n", + "import matplotlib.pyplot as plt\n", + "sns.set_theme()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "plt.figure(figsize=(10, 6))\n", + "sns.lineplot(x='closed_month', y='url', hue='mile', data=grp_df, marker='o', ci=None)\n", + "plt.xlabel('Closed Month')\n", + "plt.ylabel('ClosedAt')\n", + "plt.title('Stacked Line Chart: Milestone Effort by Issue Close Date')\n", + "plt.xticks(rotation=45)\n", + "plt.legend(title='Mile', loc='upper left')\n", + "plt.show()" ] } ], @@ -30,7 +160,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.1" + "version": "3.12.2" } }, "nbformat": 4,