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