X-Git-Url: https://apps.delaporte.us/gitweb/dotfiles.git/blobdiff_plain/47680a09b0c98441226563f1ae277efd519475ff..9cad6021b47e3b4d285c08a4f2e57cfd7b23cef0:/data/issues.ipynb diff --git a/data/issues.ipynb b/data/issues.ipynb index 3ffa40c..3340aaf 100644 --- a/data/issues.ipynb +++ b/data/issues.ipynb @@ -1,18 +1,5 @@ { "cells": [ - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "# Get ye data\n", - "import glob\n", - "import os\n", - "\n", - "data_files = glob.glob(os.path.expanduser('~\\\\Data\\\\*.json'))\n" - ] - }, { "cell_type": "code", "execution_count": 5, @@ -31,6 +18,31 @@ "print(platform.python_version())" ] }, + { + "cell_type": "code", + "execution_count": 92, + "metadata": {}, + "outputs": [], + "source": [ + "# Get ye data\n", + "import glob\n", + "import os\n", + "\n", + "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, @@ -41,13 +53,78 @@ "\n", "data_sets = []\n", "\n", - "file = data_files[0]\n", + "file = data_files[6]\n", "print(file)\n", "\n", - "f = open(file, encoding='utf-16')\n", - "data = pd.read_json(f)\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", - "print(data)\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()" ] }, { @@ -56,9 +133,13 @@ "metadata": {}, "outputs": [], "source": [ - "import maptploglib.pyplot as platform\n", - "# TODO: Get ye data into scatter plot\n", - "plt.scatter(x, y)\n", + "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()" ] }