]> apps.delaporte.us Git - dotfiles.git/blob - data/issues.ipynb
Messing with quick keys and zen mode
[dotfiles.git] / data / issues.ipynb
1 {
2 "cells": [
3 {
4 "cell_type": "code",
5 "execution_count": null,
6 "metadata": {},
7 "outputs": [
8 {
9 "ename": "",
10 "evalue": "",
11 "output_type": "error",
12 "traceback": [
13 "\u001b[1;31mRunning cells with '/bin/python3' requires the ipykernel package.\n",
14 "\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
15 "\u001b[1;31mCommand: '/bin/python3 -m pip install ipykernel -U --user --force-reinstall'"
16 ]
17 }
18 ],
19 "source": [
20 "import platform\n",
21 "import matplotlib.pyplot as plt\n",
22 "print(platform.python_version())"
23 ]
24 },
25 {
26 "cell_type": "markdown",
27 "metadata": {},
28 "source": []
29 },
30 {
31 "cell_type": "markdown",
32 "metadata": {},
33 "source": [
34 "# Todo List\n",
35 "\n",
36 "- [x] add calculated year to the metadata\n",
37 "- [ ] make one chart per year\n",
38 "- [x] make sure all the data files are getting loaded"
39 ]
40 },
41 {
42 "cell_type": "code",
43 "execution_count": null,
44 "metadata": {},
45 "outputs": [
46 {
47 "ename": "",
48 "evalue": "",
49 "output_type": "error",
50 "traceback": [
51 "\u001b[1;31mRunning cells with '/bin/python3' requires the ipykernel package.\n",
52 "\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
53 "\u001b[1;31mCommand: '/bin/python3 -m pip install ipykernel -U --user --force-reinstall'"
54 ]
55 }
56 ],
57 "source": [
58 "# Get ye data\n",
59 "import glob\n",
60 "import os\n",
61 "\n",
62 "data_files = glob.glob(os.path.expanduser('~\\\\Data\\\\*.json'))\n",
63 "\n",
64 "for file in data_files:\n",
65 "\tprint(f\"{file}\", os.path.getsize(file))\n",
66 "\n"
67 ]
68 },
69 {
70 "cell_type": "code",
71 "execution_count": null,
72 "metadata": {},
73 "outputs": [
74 {
75 "ename": "",
76 "evalue": "",
77 "output_type": "error",
78 "traceback": [
79 "\u001b[1;31mRunning cells with '/bin/python3' requires the ipykernel package.\n",
80 "\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
81 "\u001b[1;31mCommand: '/bin/python3 -m pip install ipykernel -U --user --force-reinstall'"
82 ]
83 }
84 ],
85 "source": [
86 "import pandas as pd\n",
87 "\n",
88 "data_frames = []\n",
89 "for file in data_files:\n",
90 "\n",
91 "\tf = open(file, encoding='utf-8')\n",
92 "\tdf_temp = pd.read_json(f)\n",
93 "\tdata_frames.append(df_temp)\n",
94 "\n",
95 "df = pd.concat(data_frames, ignore_index=True)"
96 ]
97 },
98 {
99 "cell_type": "code",
100 "execution_count": null,
101 "metadata": {},
102 "outputs": [
103 {
104 "ename": "",
105 "evalue": "",
106 "output_type": "error",
107 "traceback": [
108 "\u001b[1;31mRunning cells with '/bin/python3' requires the ipykernel package.\n",
109 "\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
110 "\u001b[1;31mCommand: '/bin/python3 -m pip install ipykernel -U --user --force-reinstall'"
111 ]
112 }
113 ],
114 "source": [
115 "import numpy as np\n",
116 "df['count'] = np.zeros(len(df))\n",
117 "\n"
118 ]
119 },
120 {
121 "cell_type": "markdown",
122 "metadata": {},
123 "source": [
124 "#### Pie Chart"
125 ]
126 },
127 {
128 "cell_type": "code",
129 "execution_count": null,
130 "metadata": {},
131 "outputs": [
132 {
133 "ename": "",
134 "evalue": "",
135 "output_type": "error",
136 "traceback": [
137 "\u001b[1;31mRunning cells with '/bin/python3' requires the ipykernel package.\n",
138 "\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
139 "\u001b[1;31mCommand: '/bin/python3 -m pip install ipykernel -U --user --force-reinstall'"
140 ]
141 }
142 ],
143 "source": [
144 "\n",
145 "dfp = df\n",
146 "# dfp['mile'] = [m.get('title') if m else None for m in dfp.milestone]\n",
147 "dfp['mile'] = [m.get('title') if hasattr(m, 'get') else None for m in dfp['milestone']]\n"
148 ]
149 },
150 {
151 "cell_type": "code",
152 "execution_count": null,
153 "metadata": {},
154 "outputs": [
155 {
156 "ename": "",
157 "evalue": "",
158 "output_type": "error",
159 "traceback": [
160 "\u001b[1;31mRunning cells with '/bin/python3' requires the ipykernel package.\n",
161 "\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
162 "\u001b[1;31mCommand: '/bin/python3 -m pip install ipykernel -U --user --force-reinstall'"
163 ]
164 }
165 ],
166 "source": [
167 "closed_dates = pd.to_datetime(df['closedAt'], format='ISO8601')\n",
168 "dfp['year'] = closed_dates.dt.year\n",
169 "\n",
170 "dfp.drop(columns=['closedAt','milestone', 'url'], inplace=True)\n",
171 "print(dfp)"
172 ]
173 },
174 {
175 "cell_type": "code",
176 "execution_count": null,
177 "metadata": {},
178 "outputs": [
179 {
180 "ename": "",
181 "evalue": "",
182 "output_type": "error",
183 "traceback": [
184 "\u001b[1;31mRunning cells with '/bin/python3' requires the ipykernel package.\n",
185 "\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
186 "\u001b[1;31mCommand: '/bin/python3 -m pip install ipykernel -U --user --force-reinstall'"
187 ]
188 }
189 ],
190 "source": [
191 "\n",
192 "mile_counts = dfp.groupby('mile')['title'].nunique()\n",
193 "dfp['count'] = dfp['mile'].map(mile_counts)\n",
194 "# dfp.drop(columns=['title'], inplace=True)\n",
195 "dfp['mile'] = df['mile'].drop_duplicates()\n",
196 "dfp.dropna(inplace=True)\n",
197 "dfp = dfp[dfp['count'] > 5]\n",
198 "print(dfp)"
199 ]
200 },
201 {
202 "cell_type": "code",
203 "execution_count": null,
204 "metadata": {},
205 "outputs": [
206 {
207 "ename": "",
208 "evalue": "",
209 "output_type": "error",
210 "traceback": [
211 "\u001b[1;31mRunning cells with '/bin/python3' requires the ipykernel package.\n",
212 "\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
213 "\u001b[1;31mCommand: '/bin/python3 -m pip install ipykernel -U --user --force-reinstall'"
214 ]
215 }
216 ],
217 "source": [
218 "mile_counts = df.groupby('mile')['count'].sum()\n",
219 "mile_counts = mile_counts.loc[lambda x: x > 5]\n",
220 "\n",
221 "\n",
222 "print(mile_counts)"
223 ]
224 },
225 {
226 "cell_type": "code",
227 "execution_count": null,
228 "metadata": {},
229 "outputs": [
230 {
231 "ename": "",
232 "evalue": "",
233 "output_type": "error",
234 "traceback": [
235 "\u001b[1;31mRunning cells with '/bin/python3' requires the ipykernel package.\n",
236 "\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
237 "\u001b[1;31mCommand: '/bin/python3 -m pip install ipykernel -U --user --force-reinstall'"
238 ]
239 }
240 ],
241 "source": [
242 "\n",
243 "plt.pie(mile_counts, labels=mile_counts.index, autopct='%0.1f%%')\n",
244 "plt.title(f\"Tasks by Milestone\")\n",
245 "plt.axis('equal')\n",
246 "plt.show()"
247 ]
248 },
249 {
250 "cell_type": "code",
251 "execution_count": null,
252 "metadata": {},
253 "outputs": [
254 {
255 "ename": "",
256 "evalue": "",
257 "output_type": "error",
258 "traceback": [
259 "\u001b[1;31mRunning cells with '/bin/python3' requires the ipykernel package.\n",
260 "\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
261 "\u001b[1;31mCommand: '/bin/python3 -m pip install ipykernel -U --user --force-reinstall'"
262 ]
263 }
264 ],
265 "source": [
266 "type(mile_counts)"
267 ]
268 },
269 {
270 "cell_type": "markdown",
271 "metadata": {},
272 "source": [
273 "#### Plot of closed issues by month and milestone for one project\n"
274 ]
275 },
276 {
277 "cell_type": "code",
278 "execution_count": null,
279 "metadata": {},
280 "outputs": [
281 {
282 "ename": "",
283 "evalue": "",
284 "output_type": "error",
285 "traceback": [
286 "\u001b[1;31mRunning cells with '/bin/python3' requires the ipykernel package.\n",
287 "\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
288 "\u001b[1;31mCommand: '/bin/python3 -m pip install ipykernel -U --user --force-reinstall'"
289 ]
290 }
291 ],
292 "source": [
293 "closed_months = pd.to_datetime(df['closedAt'], format='ISO8601')\n",
294 "df['closed_month'] = closed_months.dt.month\n",
295 "df.drop(columns=['closedAt'], inplace=True)"
296 ]
297 },
298 {
299 "cell_type": "code",
300 "execution_count": null,
301 "metadata": {},
302 "outputs": [
303 {
304 "ename": "",
305 "evalue": "",
306 "output_type": "error",
307 "traceback": [
308 "\u001b[1;31mRunning cells with '/bin/python3' requires the ipykernel package.\n",
309 "\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
310 "\u001b[1;31mCommand: '/bin/python3 -m pip install ipykernel -U --user --force-reinstall'"
311 ]
312 }
313 ],
314 "source": [
315 "df['mile'] = [d.get('title') if d else None for d in df.milestone]"
316 ]
317 },
318 {
319 "cell_type": "code",
320 "execution_count": null,
321 "metadata": {},
322 "outputs": [
323 {
324 "ename": "",
325 "evalue": "",
326 "output_type": "error",
327 "traceback": [
328 "\u001b[1;31mRunning cells with '/bin/python3' requires the ipykernel package.\n",
329 "\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
330 "\u001b[1;31mCommand: '/bin/python3 -m pip install ipykernel -U --user --force-reinstall'"
331 ]
332 }
333 ],
334 "source": [
335 "\n",
336 "dfg = df.groupby(['mile', 'closed_month']).count().reset_index()\n",
337 "dfg.drop(columns=['milestone', 'title', 'url'], inplace=True)\n"
338 ]
339 },
340 {
341 "cell_type": "code",
342 "execution_count": null,
343 "metadata": {},
344 "outputs": [
345 {
346 "ename": "",
347 "evalue": "",
348 "output_type": "error",
349 "traceback": [
350 "\u001b[1;31mRunning cells with '/bin/python3' requires the ipykernel package.\n",
351 "\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
352 "\u001b[1;31mCommand: '/bin/python3 -m pip install ipykernel -U --user --force-reinstall'"
353 ]
354 }
355 ],
356 "source": [
357 "exclude_from_chart = [\n",
358 "\t'Job Aid Ideas']\n",
359 "\n",
360 "for ex in exclude_from_chart:\n",
361 "\tdfg = dfg[dfg['mile'] != ex]\n"
362 ]
363 },
364 {
365 "cell_type": "code",
366 "execution_count": null,
367 "metadata": {},
368 "outputs": [
369 {
370 "ename": "",
371 "evalue": "",
372 "output_type": "error",
373 "traceback": [
374 "\u001b[1;31mRunning cells with '/bin/python3' requires the ipykernel package.\n",
375 "\u001b[1;31mRun the following command to install 'ipykernel' into the Python environment. \n",
376 "\u001b[1;31mCommand: '/bin/python3 -m pip install ipykernel -U --user --force-reinstall'"
377 ]
378 }
379 ],
380 "source": [
381 "import seaborn as sns\n",
382 "import matplotlib.pyplot as plt\n",
383 "sns.set_theme()"
384 ]
385 },
386 {
387 "cell_type": "code",
388 "execution_count": null,
389 "metadata": {},
390 "outputs": [],
391 "source": [
392 "plt.figure(figsize=(10, 6))\n",
393 "sns.pie(x='closed_month', y='count', hue='mile', data=dfg)\n",
394 "plt.pie(dfg, )\n",
395 "plt.xlabel('Closed Month')\n",
396 "plt.ylabel('ClosedAt')\n",
397 "plt.title('Stacked Line Chart: Milestone Effort by Issue Close Date')\n",
398 "plt.xticks(rotation=45)\n",
399 "plt.legend(title='Mile', loc='upper left')\n",
400 "plt.show()"
401 ]
402 }
403 ],
404 "metadata": {
405 "kernelspec": {
406 "display_name": "Python 3",
407 "language": "python",
408 "name": "python3"
409 },
410 "language_info": {
411 "codemirror_mode": {
412 "name": "ipython",
413 "version": 3
414 },
415 "file_extension": ".py",
416 "mimetype": "text/x-python",
417 "name": "python",
418 "nbconvert_exporter": "python",
419 "pygments_lexer": "ipython3",
420 "version": "3.8.10"
421 }
422 },
423 "nbformat": 4,
424 "nbformat_minor": 2
425 }