j1-template 2022.2.2 → 2022.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/_includes/themes/j1/blocks/footer/boxes/contacts_box.proc +46 -18
- data/_includes/themes/j1/blocks/footer/boxes/links_box.proc +1 -0
- data/assets/data/fab.html +2 -2
- data/assets/data/footer.html +2 -2
- data/assets/themes/j1/core/css/themes/unolight/bootstrap.css +64 -206
- data/assets/themes/j1/core/css/themes/unolight/bootstrap.min.css +2 -2
- data/assets/themes/j1/modules/nbInteract/README.md +169 -0
- data/assets/themes/j1/modules/nbInteract/css/nbinteract-core.css +4 -0
- data/assets/themes/j1/modules/nbInteract/css/nbinteract-core.min.css +4 -0
- data/lib/j1/version.rb +1 -1
- data/lib/starter_web/Gemfile +1 -1
- data/lib/starter_web/_config.yml +1 -1
- data/lib/starter_web/_data/blocks/defaults/footer.yml +25 -17
- data/lib/starter_web/_data/blocks/footer.yml +78 -65
- data/lib/starter_web/_data/resources.yml +0 -22
- data/lib/starter_web/_includes/attributes.asciidoc +14 -0
- data/lib/starter_web/_plugins/lunr_index.rb +1 -1
- data/lib/starter_web/assets/images/pages/nbinteract/nbi-textbook-example.jpg +0 -0
- data/lib/starter_web/package.json +1 -1
- data/lib/starter_web/pages/public/jupyter/docs/_includes/documents/j1_docs_example_static.asciidoc +232 -232
- data/lib/starter_web/pages/public/jupyter/docs/j1-nbinteract-doc.adoc +135 -134
- data/lib/starter_web/pages/public/jupyter/docs/nbi-widget-manual.adoc +2 -4
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_interactive_widgets-checkpoint.ipynb +170 -15
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/j1_interactive_widgets.ipynb +170 -15
- data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_recipes_interactive_questions-checkpoint.ipynb +185 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/nbi_docs_recipes_interactive_questions.ipynb +19 -22
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/binder-launches.html +670 -546
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_docs_example_dynamic.html +186 -186
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_interactive_widgets.html +919 -702
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_ode_selected.html +186 -186
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/nbi_docs_recipes_interactive_questions.html +242 -243
- data/lib/starter_web/pages/public/jupyter/{apis/binderhub-api.adoc → services/binderhub.adoc} +22 -25
- data/lib/starter_web/pages/public/jupyter/{apis/jupyterhub-api.adoc → services/jupyterhub.adoc} +2 -2
- data/lib/starter_web/pages/public/learn/roundtrip/300_icon_fonts.adoc +11 -0
- data/lib/starter_web/utilsrv/_defaults/package.json +1 -1
- data/lib/starter_web/utilsrv/package.json +1 -1
- metadata +7 -28
- data/lib/starter_web/_data/_resources.yml +0 -1668
- data/lib/starter_web/assets/images/pages/nbinteract/binderhub-architecture.png +0 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/algebra_with_sympy-checkpoint.ipynb +0 -14488
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/climate-change-forecast-checkpoint.ipynb +0 -916
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/ipympl_test_plots-checkpoint.ipynb +0 -14517
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_algebra_with_sympy-checkpoint.ipynb +0 -14517
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_altair_interactive-checkpoint.ipynb +0 -16493
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_altair_visualization-checkpoint.ipynb +0 -15358
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_altair_visualization_full-checkpoint.ipynb +0 -2576
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_climate_change_forecast-checkpoint.ipynb +0 -1058
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_climate_change_forecast.ipynb +0 -1060
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_docs_example_dynamic-checkpoint.ipynb +0 -14478
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_docs_hist-checkpoint.ipynb +0 -98
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_interactive-checkpoint.ipynb +0 -560
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_ipympl_test_plots-checkpoint.ipynb +0 -14511
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_ode_selected-checkpoint.ipynb +0 -14478
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_odes_in_python-checkpoint.ipynb +0 -14818
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_pandas_creating_reading_and_writing-checkpoint.ipynb +0 -328
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_recipes_layout-checkpoint.ipynb +0 -341
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/nbi_docs_recipes_graphing-checkpoint.ipynb +0 -98
- data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_examples_correlation-checkpoint.ipynb +0 -651
- data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_examples_variability_of_the_sample_mean-checkpoint.ipynb +0 -323
- data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_recipes_graphing-checkpoint.ipynb +0 -387
- data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_recipes_layout-checkpoint.ipynb +0 -384
@@ -1,328 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"cells": [
|
3
|
-
{
|
4
|
-
"cell_type": "code",
|
5
|
-
"execution_count": 1,
|
6
|
-
"id": "d4137d7a",
|
7
|
-
"metadata": {
|
8
|
-
"execution": {
|
9
|
-
"iopub.execute_input": "2022-02-08T16:44:11.776774Z",
|
10
|
-
"iopub.status.busy": "2022-02-08T16:44:11.775483Z",
|
11
|
-
"iopub.status.idle": "2022-02-08T16:44:11.784138Z",
|
12
|
-
"shell.execute_reply": "2022-02-08T16:44:11.784541Z"
|
13
|
-
},
|
14
|
-
"papermill": {
|
15
|
-
"duration": 0.023901,
|
16
|
-
"end_time": "2022-02-08T16:44:11.784806",
|
17
|
-
"exception": false,
|
18
|
-
"start_time": "2022-02-08T16:44:11.760905",
|
19
|
-
"status": "completed"
|
20
|
-
},
|
21
|
-
"tags": []
|
22
|
-
},
|
23
|
-
"outputs": [],
|
24
|
-
"source": [
|
25
|
-
"import warnings\n",
|
26
|
-
"# Ignore numpy dtype warnings. These warnings are caused by an interaction\n",
|
27
|
-
"# between numpy and Cython and can be safely ignored.\n",
|
28
|
-
"# Reference: https://stackoverflow.com/a/40846742\n",
|
29
|
-
"warnings.filterwarnings(\"ignore\", message=\"numpy.dtype size changed\")\n",
|
30
|
-
"warnings.filterwarnings(\"ignore\", message=\"numpy.ufunc size changed\")\n",
|
31
|
-
"\n",
|
32
|
-
"import numpy as np\n",
|
33
|
-
"import matplotlib.pyplot as plt\n",
|
34
|
-
"import pandas as pd\n",
|
35
|
-
"%matplotlib inline\n",
|
36
|
-
"import ipywidgets as widgets\n",
|
37
|
-
"from ipywidgets import interact, interactive, fixed, interact_manual\n",
|
38
|
-
"import nbinteract as nbi\n",
|
39
|
-
"\n",
|
40
|
-
"np.set_printoptions(threshold=20, precision=2, suppress=True)\n",
|
41
|
-
"pd.options.display.max_rows = 7\n",
|
42
|
-
"pd.options.display.max_columns = 8\n",
|
43
|
-
"pd.set_option('precision', 2)\n",
|
44
|
-
"# This option stops scientific notation for pandas\n",
|
45
|
-
"# pd.set_option('display.float_format', '{:.2f}'.format)"
|
46
|
-
]
|
47
|
-
},
|
48
|
-
{
|
49
|
-
"cell_type": "code",
|
50
|
-
"execution_count": 2,
|
51
|
-
"metadata": {},
|
52
|
-
"outputs": [],
|
53
|
-
"source": [
|
54
|
-
"def df_interact(df, nrows=7, ncols=7):\n",
|
55
|
-
" '''\n",
|
56
|
-
" Outputs sliders that show rows and columns of df\n",
|
57
|
-
" '''\n",
|
58
|
-
" def peek(row=0, col=0):\n",
|
59
|
-
" return df.iloc[row:row + nrows, col:col + ncols]\n",
|
60
|
-
" if len(df.columns) <= ncols:\n",
|
61
|
-
" interact(peek, row=(0, len(df) - nrows, nrows), col=fixed(0))\n",
|
62
|
-
" else:\n",
|
63
|
-
" interact(peek,\n",
|
64
|
-
" row=(0, len(df) - nrows, nrows),\n",
|
65
|
-
" col=(0, len(df.columns) - ncols))\n",
|
66
|
-
" print('({} rows, {} columns) total'.format(df.shape[0], df.shape[1]))"
|
67
|
-
]
|
68
|
-
},
|
69
|
-
{
|
70
|
-
"cell_type": "code",
|
71
|
-
"execution_count": 3,
|
72
|
-
"metadata": {},
|
73
|
-
"outputs": [],
|
74
|
-
"source": [
|
75
|
-
"videos = pd.read_csv('https://github.com/SamLau95/nbinteract/raw/master/notebooks/youtube_trending.csv',\n",
|
76
|
-
" parse_dates=['publish_time'],\n",
|
77
|
-
" index_col='publish_time')"
|
78
|
-
]
|
79
|
-
},
|
80
|
-
{
|
81
|
-
"cell_type": "code",
|
82
|
-
"execution_count": 4,
|
83
|
-
"metadata": {},
|
84
|
-
"outputs": [
|
85
|
-
{
|
86
|
-
"data": {
|
87
|
-
"text/html": [
|
88
|
-
"<div>\n",
|
89
|
-
"<style scoped>\n",
|
90
|
-
" .dataframe tbody tr th:only-of-type {\n",
|
91
|
-
" vertical-align: middle;\n",
|
92
|
-
" }\n",
|
93
|
-
"\n",
|
94
|
-
" .dataframe tbody tr th {\n",
|
95
|
-
" vertical-align: top;\n",
|
96
|
-
" }\n",
|
97
|
-
"\n",
|
98
|
-
" .dataframe thead th {\n",
|
99
|
-
" text-align: right;\n",
|
100
|
-
" }\n",
|
101
|
-
"</style>\n",
|
102
|
-
"<table border=\"1\" class=\"dataframe\">\n",
|
103
|
-
" <thead>\n",
|
104
|
-
" <tr style=\"text-align: right;\">\n",
|
105
|
-
" <th></th>\n",
|
106
|
-
" <th>title</th>\n",
|
107
|
-
" <th>channel_title</th>\n",
|
108
|
-
" <th>category_id</th>\n",
|
109
|
-
" <th>views</th>\n",
|
110
|
-
" <th>likes</th>\n",
|
111
|
-
" <th>dislikes</th>\n",
|
112
|
-
" <th>comment_count</th>\n",
|
113
|
-
" <th>category</th>\n",
|
114
|
-
" </tr>\n",
|
115
|
-
" <tr>\n",
|
116
|
-
" <th>publish_time</th>\n",
|
117
|
-
" <th></th>\n",
|
118
|
-
" <th></th>\n",
|
119
|
-
" <th></th>\n",
|
120
|
-
" <th></th>\n",
|
121
|
-
" <th></th>\n",
|
122
|
-
" <th></th>\n",
|
123
|
-
" <th></th>\n",
|
124
|
-
" <th></th>\n",
|
125
|
-
" </tr>\n",
|
126
|
-
" </thead>\n",
|
127
|
-
" <tbody>\n",
|
128
|
-
" <tr>\n",
|
129
|
-
" <th>2011-05-22 23:50:01</th>\n",
|
130
|
-
" <td>U.S. v. Whistleblower Tom Drake</td>\n",
|
131
|
-
" <td>CBS News</td>\n",
|
132
|
-
" <td>25</td>\n",
|
133
|
-
" <td>33797</td>\n",
|
134
|
-
" <td>311</td>\n",
|
135
|
-
" <td>36</td>\n",
|
136
|
-
" <td>146</td>\n",
|
137
|
-
" <td>News & Politics</td>\n",
|
138
|
-
" </tr>\n",
|
139
|
-
" <tr>\n",
|
140
|
-
" <th>2017-11-10 13:00:02</th>\n",
|
141
|
-
" <td>Tesla's biggest problem is one nobody saw coming</td>\n",
|
142
|
-
" <td>Business Insider</td>\n",
|
143
|
-
" <td>25</td>\n",
|
144
|
-
" <td>125970</td>\n",
|
145
|
-
" <td>935</td>\n",
|
146
|
-
" <td>507</td>\n",
|
147
|
-
" <td>262</td>\n",
|
148
|
-
" <td>News & Politics</td>\n",
|
149
|
-
" </tr>\n",
|
150
|
-
" <tr>\n",
|
151
|
-
" <th>2017-11-12 20:26:46</th>\n",
|
152
|
-
" <td>Some NFL players call for an end to Thursday n...</td>\n",
|
153
|
-
" <td>ABC News</td>\n",
|
154
|
-
" <td>25</td>\n",
|
155
|
-
" <td>7524</td>\n",
|
156
|
-
" <td>67</td>\n",
|
157
|
-
" <td>19</td>\n",
|
158
|
-
" <td>56</td>\n",
|
159
|
-
" <td>News & Politics</td>\n",
|
160
|
-
" </tr>\n",
|
161
|
-
" <tr>\n",
|
162
|
-
" <th>2017-11-12 21:16:40</th>\n",
|
163
|
-
" <td>Iraq-Iran earthquake: Deadly tremor hits borde...</td>\n",
|
164
|
-
" <td>BBC News</td>\n",
|
165
|
-
" <td>25</td>\n",
|
166
|
-
" <td>34785</td>\n",
|
167
|
-
" <td>308</td>\n",
|
168
|
-
" <td>26</td>\n",
|
169
|
-
" <td>413</td>\n",
|
170
|
-
" <td>News & Politics</td>\n",
|
171
|
-
" </tr>\n",
|
172
|
-
" <tr>\n",
|
173
|
-
" <th>2017-11-13 13:45:16</th>\n",
|
174
|
-
" <td>Why the rise of the robots won’t mean the end ...</td>\n",
|
175
|
-
" <td>Vox</td>\n",
|
176
|
-
" <td>25</td>\n",
|
177
|
-
" <td>256426</td>\n",
|
178
|
-
" <td>12654</td>\n",
|
179
|
-
" <td>1363</td>\n",
|
180
|
-
" <td>2368</td>\n",
|
181
|
-
" <td>News & Politics</td>\n",
|
182
|
-
" </tr>\n",
|
183
|
-
" </tbody>\n",
|
184
|
-
"</table>\n",
|
185
|
-
"</div>"
|
186
|
-
],
|
187
|
-
"text/plain": [
|
188
|
-
" title \\\n",
|
189
|
-
"publish_time \n",
|
190
|
-
"2011-05-22 23:50:01 U.S. v. Whistleblower Tom Drake \n",
|
191
|
-
"2017-11-10 13:00:02 Tesla's biggest problem is one nobody saw coming \n",
|
192
|
-
"2017-11-12 20:26:46 Some NFL players call for an end to Thursday n... \n",
|
193
|
-
"2017-11-12 21:16:40 Iraq-Iran earthquake: Deadly tremor hits borde... \n",
|
194
|
-
"2017-11-13 13:45:16 Why the rise of the robots won’t mean the end ... \n",
|
195
|
-
"\n",
|
196
|
-
" channel_title category_id views likes dislikes \\\n",
|
197
|
-
"publish_time \n",
|
198
|
-
"2011-05-22 23:50:01 CBS News 25 33797 311 36 \n",
|
199
|
-
"2017-11-10 13:00:02 Business Insider 25 125970 935 507 \n",
|
200
|
-
"2017-11-12 20:26:46 ABC News 25 7524 67 19 \n",
|
201
|
-
"2017-11-12 21:16:40 BBC News 25 34785 308 26 \n",
|
202
|
-
"2017-11-13 13:45:16 Vox 25 256426 12654 1363 \n",
|
203
|
-
"\n",
|
204
|
-
" comment_count category \n",
|
205
|
-
"publish_time \n",
|
206
|
-
"2011-05-22 23:50:01 146 News & Politics \n",
|
207
|
-
"2017-11-10 13:00:02 262 News & Politics \n",
|
208
|
-
"2017-11-12 20:26:46 56 News & Politics \n",
|
209
|
-
"2017-11-12 21:16:40 413 News & Politics \n",
|
210
|
-
"2017-11-13 13:45:16 2368 News & Politics "
|
211
|
-
]
|
212
|
-
},
|
213
|
-
"execution_count": 4,
|
214
|
-
"metadata": {},
|
215
|
-
"output_type": "execute_result"
|
216
|
-
}
|
217
|
-
],
|
218
|
-
"source": [
|
219
|
-
"videos.head()"
|
220
|
-
]
|
221
|
-
},
|
222
|
-
{
|
223
|
-
"cell_type": "code",
|
224
|
-
"execution_count": 5,
|
225
|
-
"metadata": {},
|
226
|
-
"outputs": [
|
227
|
-
{
|
228
|
-
"data": {
|
229
|
-
"application/vnd.jupyter.widget-view+json": {
|
230
|
-
"model_id": "4d1ed5d14df44836a3de89a5fb8bec2a",
|
231
|
-
"version_major": 2,
|
232
|
-
"version_minor": 0
|
233
|
-
},
|
234
|
-
"text/plain": [
|
235
|
-
"interactive(children=(IntSlider(value=0, description='row', max=2428, step=7), IntSlider(value=0, description=…"
|
236
|
-
]
|
237
|
-
},
|
238
|
-
"metadata": {},
|
239
|
-
"output_type": "display_data"
|
240
|
-
},
|
241
|
-
{
|
242
|
-
"name": "stdout",
|
243
|
-
"output_type": "stream",
|
244
|
-
"text": [
|
245
|
-
"(2435 rows, 8 columns) total\n"
|
246
|
-
]
|
247
|
-
}
|
248
|
-
],
|
249
|
-
"source": [
|
250
|
-
"df_interact(videos)"
|
251
|
-
]
|
252
|
-
},
|
253
|
-
{
|
254
|
-
"cell_type": "code",
|
255
|
-
"execution_count": 6,
|
256
|
-
"metadata": {},
|
257
|
-
"outputs": [],
|
258
|
-
"source": [
|
259
|
-
"wine_reviews = pd.read_csv(\"https://github.com/jekyll-one/nbinteract-notebooks/raw/main/data/winemag-data-130k-v2.csv.zip\")\n",
|
260
|
-
"my_review = wine_reviews.head(100)"
|
261
|
-
]
|
262
|
-
},
|
263
|
-
{
|
264
|
-
"cell_type": "code",
|
265
|
-
"execution_count": 7,
|
266
|
-
"metadata": {},
|
267
|
-
"outputs": [
|
268
|
-
{
|
269
|
-
"data": {
|
270
|
-
"application/vnd.jupyter.widget-view+json": {
|
271
|
-
"model_id": "bac533541b77479d86bf972294df6d38",
|
272
|
-
"version_major": 2,
|
273
|
-
"version_minor": 0
|
274
|
-
},
|
275
|
-
"text/plain": [
|
276
|
-
"interactive(children=(IntSlider(value=0, description='row', max=93, step=7), IntSlider(value=0, description='c…"
|
277
|
-
]
|
278
|
-
},
|
279
|
-
"metadata": {},
|
280
|
-
"output_type": "display_data"
|
281
|
-
},
|
282
|
-
{
|
283
|
-
"name": "stdout",
|
284
|
-
"output_type": "stream",
|
285
|
-
"text": [
|
286
|
-
"(100 rows, 14 columns) total\n"
|
287
|
-
]
|
288
|
-
}
|
289
|
-
],
|
290
|
-
"source": [
|
291
|
-
"df_interact(my_review)"
|
292
|
-
]
|
293
|
-
}
|
294
|
-
],
|
295
|
-
"metadata": {
|
296
|
-
"kernelspec": {
|
297
|
-
"display_name": "Python 3",
|
298
|
-
"language": "python",
|
299
|
-
"name": "python3"
|
300
|
-
},
|
301
|
-
"language_info": {
|
302
|
-
"codemirror_mode": {
|
303
|
-
"name": "ipython",
|
304
|
-
"version": 3
|
305
|
-
},
|
306
|
-
"file_extension": ".py",
|
307
|
-
"mimetype": "text/x-python",
|
308
|
-
"name": "python",
|
309
|
-
"nbconvert_exporter": "python",
|
310
|
-
"pygments_lexer": "ipython3",
|
311
|
-
"version": "3.7.9"
|
312
|
-
},
|
313
|
-
"papermill": {
|
314
|
-
"default_parameters": {},
|
315
|
-
"duration": 12.263247,
|
316
|
-
"end_time": "2022-02-08T16:44:15.771485",
|
317
|
-
"environment_variables": {},
|
318
|
-
"exception": null,
|
319
|
-
"input_path": "__notebook__.ipynb",
|
320
|
-
"output_path": "__notebook__.ipynb",
|
321
|
-
"parameters": {},
|
322
|
-
"start_time": "2022-02-08T16:44:03.508238",
|
323
|
-
"version": "2.3.3"
|
324
|
-
}
|
325
|
-
},
|
326
|
-
"nbformat": 4,
|
327
|
-
"nbformat_minor": 5
|
328
|
-
}
|
@@ -1,341 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"cells": [
|
3
|
-
{
|
4
|
-
"cell_type": "code",
|
5
|
-
"execution_count": 1,
|
6
|
-
"metadata": {},
|
7
|
-
"outputs": [],
|
8
|
-
"source": [
|
9
|
-
"# nbi:hide_in\n",
|
10
|
-
"import warnings\n",
|
11
|
-
"# Ignore numpy dtype warnings. These warnings are caused by an interaction\n",
|
12
|
-
"# between numpy and Cython and can be safely ignored.\n",
|
13
|
-
"# Reference: https://stackoverflow.com/a/40846742\n",
|
14
|
-
"warnings.filterwarnings(\"ignore\", message=\"numpy.dtype size changed\")\n",
|
15
|
-
"warnings.filterwarnings(\"ignore\", message=\"numpy.ufunc size changed\")\n",
|
16
|
-
"\n",
|
17
|
-
"import numpy as np\n",
|
18
|
-
"import matplotlib.pyplot as plt\n",
|
19
|
-
"import pandas as pd\n",
|
20
|
-
"%matplotlib inline\n",
|
21
|
-
"import ipywidgets as widgets\n",
|
22
|
-
"from ipywidgets import interact, interactive, fixed, interact_manual\n",
|
23
|
-
"import nbinteract as nbi\n",
|
24
|
-
"\n",
|
25
|
-
"np.set_printoptions(threshold=20, precision=2, suppress=True)\n",
|
26
|
-
"pd.options.display.max_rows = 7\n",
|
27
|
-
"pd.options.display.max_columns = 8\n",
|
28
|
-
"pd.set_option('precision', 2)\n",
|
29
|
-
"# This option stops scientific notation for pandas\n",
|
30
|
-
"# pd.set_option('display.float_format', '{:.2f}'.format)"
|
31
|
-
]
|
32
|
-
},
|
33
|
-
{
|
34
|
-
"cell_type": "code",
|
35
|
-
"execution_count": 2,
|
36
|
-
"metadata": {},
|
37
|
-
"outputs": [],
|
38
|
-
"source": [
|
39
|
-
"# nbi:hide_in\n",
|
40
|
-
"def df_interact(df, nrows=7, ncols=7):\n",
|
41
|
-
" '''\n",
|
42
|
-
" Outputs sliders that show rows and columns of df\n",
|
43
|
-
" '''\n",
|
44
|
-
" def peek(row=0, col=0):\n",
|
45
|
-
" return df.iloc[row:row + nrows, col:col + ncols]\n",
|
46
|
-
" if len(df.columns) <= ncols:\n",
|
47
|
-
" interact(peek, row=(0, len(df) - nrows, nrows), col=fixed(0))\n",
|
48
|
-
" else:\n",
|
49
|
-
" interact(peek,\n",
|
50
|
-
" row=(0, len(df) - nrows, nrows),\n",
|
51
|
-
" col=(0, len(df.columns) - ncols))\n",
|
52
|
-
" print('({} rows, {} columns) total'.format(df.shape[0], df.shape[1]))"
|
53
|
-
]
|
54
|
-
},
|
55
|
-
{
|
56
|
-
"cell_type": "code",
|
57
|
-
"execution_count": 3,
|
58
|
-
"metadata": {},
|
59
|
-
"outputs": [],
|
60
|
-
"source": [
|
61
|
-
"# nbi:hide_in\n",
|
62
|
-
"videos = pd.read_csv('https://github.com/SamLau95/nbinteract/raw/master/notebooks/youtube_trending.csv',\n",
|
63
|
-
" parse_dates=['publish_time'],\n",
|
64
|
-
" index_col='publish_time')"
|
65
|
-
]
|
66
|
-
},
|
67
|
-
{
|
68
|
-
"cell_type": "markdown",
|
69
|
-
"metadata": {},
|
70
|
-
"source": [
|
71
|
-
"### Page Layout and Dashboarding\n",
|
72
|
-
"`nbinteract` gives basic page layout functionality using special comments in your code. Include one or more of these markers in a Python comment and `nbinteract` will add their corresponding CSS classes to the generated cells.\n",
|
73
|
-
"\n",
|
74
|
-
"| Marker | Description | CSS class added |\n",
|
75
|
-
"| --------- | --------- | --------- |\n",
|
76
|
-
"| `nbi:left` | Floats cell to the left | `nbinteract-left` |\n",
|
77
|
-
"| `nbi:right` | Floats cell to the right | `nbinteract-right` |\n",
|
78
|
-
"| `nbi:hide_in` | Hides cell input | `nbinteract-hide_in` |\n",
|
79
|
-
"| `nbi:hide_out` | Hides cell output | `nbinteract-hide_out` |\n",
|
80
|
-
"\n",
|
81
|
-
"By default, only the `full` template will automatically provide styling for these classes. For other templates, `nbinteract` assumes that the embedding page will use the CSS classes to style the cells.\n",
|
82
|
-
"\n",
|
83
|
-
"You can use the layout markers to create simple dashboards. In this page, we create a dashboard using a dataset of trending videos on YouTube. We first create a dashboard showing the code used to generate the plots. Further down the page, we replicate the dashboard without showing the code."
|
84
|
-
]
|
85
|
-
},
|
86
|
-
{
|
87
|
-
"cell_type": "code",
|
88
|
-
"execution_count": 4,
|
89
|
-
"metadata": {},
|
90
|
-
"outputs": [
|
91
|
-
{
|
92
|
-
"data": {
|
93
|
-
"application/vnd.jupyter.widget-view+json": {
|
94
|
-
"model_id": "e0125ef8a64f48d68c4f459623f3be93",
|
95
|
-
"version_major": 2,
|
96
|
-
"version_minor": 0
|
97
|
-
},
|
98
|
-
"text/plain": [
|
99
|
-
"interactive(children=(IntSlider(value=0, description='row', max=2428, step=7), IntSlider(value=0, description=…"
|
100
|
-
]
|
101
|
-
},
|
102
|
-
"metadata": {},
|
103
|
-
"output_type": "display_data"
|
104
|
-
},
|
105
|
-
{
|
106
|
-
"name": "stdout",
|
107
|
-
"output_type": "stream",
|
108
|
-
"text": [
|
109
|
-
"(2435 rows, 8 columns) total\n"
|
110
|
-
]
|
111
|
-
}
|
112
|
-
],
|
113
|
-
"source": [
|
114
|
-
"df_interact(videos)"
|
115
|
-
]
|
116
|
-
},
|
117
|
-
{
|
118
|
-
"cell_type": "code",
|
119
|
-
"execution_count": 5,
|
120
|
-
"metadata": {},
|
121
|
-
"outputs": [
|
122
|
-
{
|
123
|
-
"data": {
|
124
|
-
"application/vnd.jupyter.widget-view+json": {
|
125
|
-
"model_id": "29a0ed22c7494de7a593d3399c7135a1",
|
126
|
-
"version_major": 2,
|
127
|
-
"version_minor": 0
|
128
|
-
},
|
129
|
-
"text/plain": [
|
130
|
-
"VBox(children=(interactive(children=(Dropdown(description='channel', options=('The View', 'CBS This Morning', …"
|
131
|
-
]
|
132
|
-
},
|
133
|
-
"metadata": {},
|
134
|
-
"output_type": "display_data"
|
135
|
-
}
|
136
|
-
],
|
137
|
-
"source": [
|
138
|
-
"# nbi:left\n",
|
139
|
-
"options = {\n",
|
140
|
-
" 'title': 'Views for Trending Videos',\n",
|
141
|
-
" 'xlabel': 'Date Trending',\n",
|
142
|
-
" 'ylabel': 'Views',\n",
|
143
|
-
" 'animation_duration': 500,\n",
|
144
|
-
" 'aspect_ratio': 1.0,\n",
|
145
|
-
"}\n",
|
146
|
-
"\n",
|
147
|
-
"def xs(channel):\n",
|
148
|
-
" return videos.loc[videos['channel_title'] == channel].index\n",
|
149
|
-
"\n",
|
150
|
-
"def ys(xs):\n",
|
151
|
-
" return videos.loc[xs, 'views']\n",
|
152
|
-
"\n",
|
153
|
-
"nbi.scatter(xs, ys,\n",
|
154
|
-
" channel=videos['channel_title'].unique()[9:15],\n",
|
155
|
-
" options=options)"
|
156
|
-
]
|
157
|
-
},
|
158
|
-
{
|
159
|
-
"cell_type": "code",
|
160
|
-
"execution_count": 6,
|
161
|
-
"metadata": {},
|
162
|
-
"outputs": [
|
163
|
-
{
|
164
|
-
"data": {
|
165
|
-
"application/vnd.jupyter.widget-view+json": {
|
166
|
-
"model_id": "534e4ac50eeb4e0fbc11b905c5cb541f",
|
167
|
-
"version_major": 2,
|
168
|
-
"version_minor": 0
|
169
|
-
},
|
170
|
-
"text/plain": [
|
171
|
-
"VBox(children=(interactive(children=(ToggleButtons(description='col', options=('views', 'likes', 'dislikes', '…"
|
172
|
-
]
|
173
|
-
},
|
174
|
-
"metadata": {},
|
175
|
-
"output_type": "display_data"
|
176
|
-
}
|
177
|
-
],
|
178
|
-
"source": [
|
179
|
-
"# nbi:right\n",
|
180
|
-
"options={\n",
|
181
|
-
" 'ylabel': 'Proportion per Unit',\n",
|
182
|
-
" 'bins': 100,\n",
|
183
|
-
" 'aspect_ratio': 1.0,\n",
|
184
|
-
"}\n",
|
185
|
-
"\n",
|
186
|
-
"\n",
|
187
|
-
"def values(col):\n",
|
188
|
-
" vals = videos[col]\n",
|
189
|
-
" return vals[vals < vals.quantile(0.8)]\n",
|
190
|
-
"\n",
|
191
|
-
"nbi.hist(values, col=widgets.ToggleButtons(options=['views', 'likes', 'dislikes', 'comment_count']), options=options)"
|
192
|
-
]
|
193
|
-
},
|
194
|
-
{
|
195
|
-
"cell_type": "markdown",
|
196
|
-
"metadata": {},
|
197
|
-
"source": [
|
198
|
-
" "
|
199
|
-
]
|
200
|
-
},
|
201
|
-
{
|
202
|
-
"cell_type": "markdown",
|
203
|
-
"metadata": {},
|
204
|
-
"source": [
|
205
|
-
"#### Dashboard (without showing code)"
|
206
|
-
]
|
207
|
-
},
|
208
|
-
{
|
209
|
-
"cell_type": "code",
|
210
|
-
"execution_count": 7,
|
211
|
-
"metadata": {},
|
212
|
-
"outputs": [
|
213
|
-
{
|
214
|
-
"data": {
|
215
|
-
"application/vnd.jupyter.widget-view+json": {
|
216
|
-
"model_id": "d780bd58810c4f03a20c29b6220b7924",
|
217
|
-
"version_major": 2,
|
218
|
-
"version_minor": 0
|
219
|
-
},
|
220
|
-
"text/plain": [
|
221
|
-
"interactive(children=(IntSlider(value=0, description='row', max=2428, step=7), IntSlider(value=0, description=…"
|
222
|
-
]
|
223
|
-
},
|
224
|
-
"metadata": {},
|
225
|
-
"output_type": "display_data"
|
226
|
-
},
|
227
|
-
{
|
228
|
-
"name": "stdout",
|
229
|
-
"output_type": "stream",
|
230
|
-
"text": [
|
231
|
-
"(2435 rows, 8 columns) total\n"
|
232
|
-
]
|
233
|
-
}
|
234
|
-
],
|
235
|
-
"source": [
|
236
|
-
"# nbi:hide_in\n",
|
237
|
-
"df_interact(videos)"
|
238
|
-
]
|
239
|
-
},
|
240
|
-
{
|
241
|
-
"cell_type": "code",
|
242
|
-
"execution_count": 8,
|
243
|
-
"metadata": {},
|
244
|
-
"outputs": [
|
245
|
-
{
|
246
|
-
"data": {
|
247
|
-
"application/vnd.jupyter.widget-view+json": {
|
248
|
-
"model_id": "031a7cdc657249949261954d56569292",
|
249
|
-
"version_major": 2,
|
250
|
-
"version_minor": 0
|
251
|
-
},
|
252
|
-
"text/plain": [
|
253
|
-
"VBox(children=(interactive(children=(Dropdown(description='channel', options=('The View', 'CBS This Morning', …"
|
254
|
-
]
|
255
|
-
},
|
256
|
-
"metadata": {},
|
257
|
-
"output_type": "display_data"
|
258
|
-
}
|
259
|
-
],
|
260
|
-
"source": [
|
261
|
-
"# nbi:hide_in\n",
|
262
|
-
"# nbi:left\n",
|
263
|
-
"options = {\n",
|
264
|
-
" 'title': 'Views for Trending Videos',\n",
|
265
|
-
" 'xlabel': 'Date Trending',\n",
|
266
|
-
" 'ylabel': 'Views',\n",
|
267
|
-
" 'animation_duration': 500,\n",
|
268
|
-
" 'aspect_ratio': 1.0,\n",
|
269
|
-
"}\n",
|
270
|
-
"\n",
|
271
|
-
"def xs(channel):\n",
|
272
|
-
" return videos.loc[videos['channel_title'] == channel].index\n",
|
273
|
-
"\n",
|
274
|
-
"def ys(xs):\n",
|
275
|
-
" return videos.loc[xs, 'views']\n",
|
276
|
-
"\n",
|
277
|
-
"nbi.scatter(xs, ys,\n",
|
278
|
-
" channel=videos['channel_title'].unique()[9:15],\n",
|
279
|
-
" options=options)"
|
280
|
-
]
|
281
|
-
},
|
282
|
-
{
|
283
|
-
"cell_type": "code",
|
284
|
-
"execution_count": 9,
|
285
|
-
"metadata": {},
|
286
|
-
"outputs": [
|
287
|
-
{
|
288
|
-
"data": {
|
289
|
-
"application/vnd.jupyter.widget-view+json": {
|
290
|
-
"model_id": "b947b2cbb59d456fb44049b4e132df1d",
|
291
|
-
"version_major": 2,
|
292
|
-
"version_minor": 0
|
293
|
-
},
|
294
|
-
"text/plain": [
|
295
|
-
"VBox(children=(interactive(children=(ToggleButtons(description='col', options=('views', 'likes', 'dislikes', '…"
|
296
|
-
]
|
297
|
-
},
|
298
|
-
"metadata": {},
|
299
|
-
"output_type": "display_data"
|
300
|
-
}
|
301
|
-
],
|
302
|
-
"source": [
|
303
|
-
"# nbi:hide_in\n",
|
304
|
-
"# nbi:right\n",
|
305
|
-
"options={\n",
|
306
|
-
" 'ylabel': 'Proportion per Unit',\n",
|
307
|
-
" 'bins': 100,\n",
|
308
|
-
" 'aspect_ratio': 1.0,\n",
|
309
|
-
"}\n",
|
310
|
-
"\n",
|
311
|
-
"\n",
|
312
|
-
"def values(col):\n",
|
313
|
-
" vals = videos[col]\n",
|
314
|
-
" return vals[vals < vals.quantile(0.8)]\n",
|
315
|
-
"\n",
|
316
|
-
"nbi.hist(values, col=widgets.ToggleButtons(options=['views', 'likes', 'dislikes', 'comment_count']), options=options)"
|
317
|
-
]
|
318
|
-
}
|
319
|
-
],
|
320
|
-
"metadata": {
|
321
|
-
"kernelspec": {
|
322
|
-
"display_name": "Python 3",
|
323
|
-
"language": "python",
|
324
|
-
"name": "python3"
|
325
|
-
},
|
326
|
-
"language_info": {
|
327
|
-
"codemirror_mode": {
|
328
|
-
"name": "ipython",
|
329
|
-
"version": 3
|
330
|
-
},
|
331
|
-
"file_extension": ".py",
|
332
|
-
"mimetype": "text/x-python",
|
333
|
-
"name": "python",
|
334
|
-
"nbconvert_exporter": "python",
|
335
|
-
"pygments_lexer": "ipython3",
|
336
|
-
"version": "3.7.9"
|
337
|
-
}
|
338
|
-
},
|
339
|
-
"nbformat": 4,
|
340
|
-
"nbformat_minor": 2
|
341
|
-
}
|