]> apps.delaporte.us Git - dotfiles.git/blob - data/issues.ipynb
Add ability to exclude milestones to allow focus on bigger ones
[dotfiles.git] / data / issues.ipynb
1 {
2 "cells": [
3 {
4 "cell_type": "code",
5 "execution_count": null,
6 "metadata": {},
7 "outputs": [],
8 "source": [
9 "import platform\n",
10 "print(platform.python_version())"
11 ]
12 },
13 {
14 "cell_type": "code",
15 "execution_count": null,
16 "metadata": {},
17 "outputs": [],
18 "source": [
19 "# Get ye data\n",
20 "import glob\n",
21 "import os\n",
22 "\n",
23 "data_files = glob.glob(os.path.expanduser('~\\\\Data\\\\*.json'))\n"
24 ]
25 },
26 {
27 "cell_type": "code",
28 "execution_count": null,
29 "metadata": {},
30 "outputs": [],
31 "source": [
32 "import os\n",
33 "\n",
34 "for file in data_files:\n",
35 "\tprint(f\"{file}\", os.path.getsize(file))\n"
36 ]
37 },
38 {
39 "cell_type": "code",
40 "execution_count": null,
41 "metadata": {},
42 "outputs": [],
43 "source": [
44 "import pandas as pd\n",
45 "\n",
46 "data_sets = []\n",
47 "\n",
48 "file = data_files[2]\n",
49 "print(file)\n",
50 "\n",
51 "f = open(file, encoding='utf-8')\n",
52 "df = pd.read_json(f)"
53 ]
54 },
55 {
56 "cell_type": "code",
57 "execution_count": null,
58 "metadata": {},
59 "outputs": [],
60 "source": [
61 "import numpy as np\n",
62 "df['count'] = np.zeros(len(df))\n",
63 "\n"
64 ]
65 },
66 {
67 "cell_type": "code",
68 "execution_count": null,
69 "metadata": {},
70 "outputs": [],
71 "source": [
72 "closed_months = pd.to_datetime(df['closedAt'], format='ISO8601')\n",
73 "df['closed_month'] = closed_months.dt.month\n",
74 "df.drop(columns=['closedAt'], inplace=True)"
75 ]
76 },
77 {
78 "cell_type": "code",
79 "execution_count": null,
80 "metadata": {},
81 "outputs": [],
82 "source": [
83 "df['mile'] = [d.get('title') if d else None for d in df.milestone]"
84 ]
85 },
86 {
87 "cell_type": "code",
88 "execution_count": null,
89 "metadata": {},
90 "outputs": [],
91 "source": [
92 "\n",
93 "dfg = df.groupby(['mile', 'closed_month']).count().reset_index()\n",
94 "dfg.drop(columns=['milestone', 'title', 'url'], inplace=True)\n"
95 ]
96 },
97 {
98 "cell_type": "code",
99 "execution_count": null,
100 "metadata": {},
101 "outputs": [],
102 "source": [
103 "\n",
104 "print(dfg)"
105 ]
106 },
107 {
108 "cell_type": "markdown",
109 "metadata": {},
110 "source": [
111 "#### Plot of closed issues by month and milestone for one project\n"
112 ]
113 },
114 {
115 "cell_type": "code",
116 "execution_count": 32,
117 "metadata": {},
118 "outputs": [],
119 "source": [
120 "exclude_from_chart = [\n",
121 "\t'Job Aid Ideas']\n",
122 "\n",
123 "for ex in exclude_from_chart:\n",
124 "\tdfg = dfg[dfg['mile'] != ex]\n"
125 ]
126 },
127 {
128 "cell_type": "code",
129 "execution_count": null,
130 "metadata": {},
131 "outputs": [],
132 "source": [
133 "import seaborn as sns\n",
134 "import matplotlib.pyplot as plt\n",
135 "sns.set_theme()"
136 ]
137 },
138 {
139 "cell_type": "code",
140 "execution_count": null,
141 "metadata": {},
142 "outputs": [],
143 "source": [
144 "plt.figure(figsize=(10, 6))\n",
145 "sns.barplot(x='closed_month', y='count', hue='mile', data=dfg)\n",
146 "plt.xlabel('Closed Month')\n",
147 "plt.ylabel('ClosedAt')\n",
148 "plt.title('Stacked Line Chart: Milestone Effort by Issue Close Date')\n",
149 "plt.xticks(rotation=45)\n",
150 "plt.legend(title='Mile', loc='upper left')\n",
151 "plt.show()"
152 ]
153 }
154 ],
155 "metadata": {
156 "kernelspec": {
157 "display_name": "Python 3",
158 "language": "python",
159 "name": "python3"
160 },
161 "language_info": {
162 "codemirror_mode": {
163 "name": "ipython",
164 "version": 3
165 },
166 "file_extension": ".py",
167 "mimetype": "text/x-python",
168 "name": "python",
169 "nbconvert_exporter": "python",
170 "pygments_lexer": "ipython3",
171 "version": "3.12.2"
172 }
173 },
174 "nbformat": 4,
175 "nbformat_minor": 2
176 }