-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathjupyter-notebooks.html
More file actions
479 lines (414 loc) · 19.2 KB
/
jupyter-notebooks.html
File metadata and controls
479 lines (414 loc) · 19.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="images/logo.png">
<link rel="apple-touch-icon" href="images/logo.png">
<title>Jupyter Notebooks - Developer Toolkit | DevDunia</title>
<meta name="description" content="Jupyter Notebook setup, magic commands, and data visualization examples. Free online Jupyter Notebook reference for developers.">
<script src="https://cdn.tailwindcss.com"></script>
<script src="js/common.js"></script>
<style>
body {
background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}
</style>
</head>
<body class="h-screen lg:ml-72">
<!-- Background: Consistent Subtle Dark Gradient -->
<div class="fixed inset-0 -z-10 bg-gradient-to-br from-gray-900 via-slate-900 to-gray-900"></div>
<!-- Main Container -->
<div class="main-content">
<div class="relative z-10 container mx-auto px-4 pt-16 pb-24 sm:px-6 lg:px-8">
<!-- Page Header -->
<div class="text-center mb-12">
<h1 class="text-3xl sm:text-4xl font-bold mb-4 tracking-tight
text-transparent bg-clip-text bg-gradient-to-r from-emerald-400 to-teal-500">
Jupyter Notebooks
</h1>
<p class="text-lg text-gray-400 max-w-2xl mx-auto">
Notebook setup, magic commands, and data visualization examples.
</p>
</div>
<!-- Tool Container -->
<div class="max-w-6xl mx-auto">
<div class="bg-slate-800/70 backdrop-blur-md rounded-lg shadow-lg border border-slate-700/60 p-6">
<!-- Setup Section -->
<div class="mb-8">
<h2 class="text-xl font-semibold text-emerald-300 mb-4">Setup & Installation</h2>
<div class="bg-slate-700/30 rounded-lg p-4 border border-slate-600/50">
<div class="flex items-center justify-between mb-3">
<h3 class="text-lg font-medium text-emerald-300">Installation & Basic Setup</h3>
<button class="copy-btn px-3 py-1 bg-emerald-600 hover:bg-emerald-700 text-white text-xs rounded transition-colors duration-200 flex items-center space-x-1" data-target="setup-code">
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v8a2 2 0 01-2 2h-2m-6-4l2 2m0 0l2-2m-2 2V10"></path>
</svg>
<span>Copy</span>
</button>
</div>
<textarea
id="setup-code"
rows="10"
class="w-full px-3 py-2 bg-slate-800/50 border border-slate-600 rounded text-gray-200 font-mono text-sm resize-none"
readonly
># Install Jupyter
pip install jupyter
# Install additional packages
pip install jupyterlab
pip install ipywidgets
pip install matplotlib seaborn pandas numpy
# Start Jupyter Notebook
jupyter notebook
# Start JupyterLab (modern interface)
jupyter lab
# Create a new notebook
jupyter notebook my_notebook.ipynb
# Convert notebook to different formats
jupyter nbconvert --to html my_notebook.ipynb
jupyter nbconvert --to pdf my_notebook.ipynb
jupyter nbconvert --to python my_notebook.ipynb
# Install extensions
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user</textarea>
</div>
</div>
<!-- Magic Commands Section -->
<div class="mb-8">
<h2 class="text-xl font-semibold text-emerald-300 mb-4">Magic Commands</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<!-- Line Magic Commands -->
<div class="bg-slate-700/30 rounded-lg p-4 border border-slate-600/50">
<div class="flex items-center justify-between mb-3">
<h3 class="text-lg font-medium text-emerald-300">Line Magic Commands</h3>
<button class="copy-btn px-3 py-1 bg-emerald-600 hover:bg-emerald-700 text-white text-xs rounded transition-colors duration-200 flex items-center space-x-1" data-target="line-magic-code">
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v8a2 2 0 01-2 2h-2m-6-4l2 2m0 0l2-2m-2 2V10"></path>
</svg>
<span>Copy</span>
</button>
</div>
<textarea
id="line-magic-code"
rows="15"
class="w-full px-3 py-2 bg-slate-800/50 border border-slate-600 rounded text-gray-200 font-mono text-sm resize-none"
readonly
># Timing and profiling
%time sum(range(1000000))
%timeit sum(range(1000000))
# System commands
%pwd # Current directory
%ls # List files
%cd /path/to/directory # Change directory
%mkdir new_folder # Create directory
# Environment and variables
%env # Show environment variables
%env MY_VAR=value # Set environment variable
%who # Show all variables
%whos # Show variables with details
%del variable_name # Delete variable
# History and debugging
%history # Show command history
%debug # Enter debugger
%pdb on # Auto-enter debugger on error
# File operations
%load filename.py # Load Python file
%run filename.py # Run Python file
%save filename.py 1-5 # Save lines 1-5 to file
# Display options
%matplotlib inline # Show plots inline
%matplotlib notebook # Interactive plots
%config InlineBackend.figure_format = 'svg' # SVG format</textarea>
</div>
<!-- Cell Magic Commands -->
<div class="bg-slate-700/30 rounded-lg p-4 border border-slate-600/50">
<div class="flex items-center justify-between mb-3">
<h3 class="text-lg font-medium text-emerald-300">Cell Magic Commands</h3>
<button class="copy-btn px-3 py-1 bg-emerald-600 hover:bg-emerald-700 text-white text-xs rounded transition-colors duration-200 flex items-center space-x-1" data-target="cell-magic-code">
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v8a2 2 0 01-2 2h-2m-6-4l2 2m0 0l2-2m-2 2V10"></path>
</svg>
<span>Copy</span>
</button>
</div>
<textarea
id="cell-magic-code"
rows="15"
class="w-full px-3 py-2 bg-slate-800/50 border border-slate-600 rounded text-gray-200 font-mono text-sm resize-none"
readonly
># Run different languages
%%bash
echo "Hello from Bash!"
ls -la
%%html
<h1>Hello from HTML!</h1>
<p>This is HTML content in a notebook cell.</p>
%%javascript
console.log("Hello from JavaScript!");
alert("Hello World!");
%%latex
\begin{equation}
E = mc^2
\end{equation}
# File operations
%%writefile my_script.py
def hello():
print("Hello from external file!")
%%writefile -a my_script.py
def goodbye():
print("Goodbye!")
# Capture output
%%capture captured_output
print("This output will be captured")
result = 42
# Show captured output
captured_output.show()
# Suppress output
%%capture
import warnings
warnings.filterwarnings('ignore')
print("This won't be displayed")</textarea>
</div>
</div>
</div>
<!-- Data Visualization Section -->
<div class="mb-8">
<h2 class="text-xl font-semibold text-emerald-300 mb-4">Data Visualization</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<!-- Matplotlib Examples -->
<div class="bg-slate-700/30 rounded-lg p-4 border border-slate-600/50">
<div class="flex items-center justify-between mb-3">
<h3 class="text-lg font-medium text-emerald-300">Matplotlib Examples</h3>
<button class="copy-btn px-3 py-1 bg-emerald-600 hover:bg-emerald-700 text-white text-xs rounded transition-colors duration-200 flex items-center space-x-1" data-target="matplotlib-code">
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v8a2 2 0 01-2 2h-2m-6-4l2 2m0 0l2-2m-2 2V10"></path>
</svg>
<span>Copy</span>
</button>
</div>
<textarea
id="matplotlib-code"
rows="15"
class="w-full px-3 py-2 bg-slate-800/50 border border-slate-600 rounded text-gray-200 font-mono text-sm resize-none"
readonly
>import matplotlib.pyplot as plt
import numpy as np
# Basic plot
x = np.linspace(0, 10, 100)
y = np.sin(x)
plt.figure(figsize=(10, 6))
plt.plot(x, y, 'b-', linewidth=2, label='sin(x)')
plt.xlabel('X values')
plt.ylabel('Y values')
plt.title('Sine Wave')
plt.legend()
plt.grid(True)
plt.show()
# Multiple subplots
fig, axes = plt.subplots(2, 2, figsize=(12, 8))
# Subplot 1: Line plot
x = np.linspace(0, 10, 100)
axes[0, 0].plot(x, np.sin(x))
axes[0, 0].set_title('Sine Wave')
# Subplot 2: Scatter plot
x = np.random.randn(100)
y = np.random.randn(100)
axes[0, 1].scatter(x, y, alpha=0.6)
axes[0, 1].set_title('Scatter Plot')
# Subplot 3: Histogram
data = np.random.randn(1000)
axes[1, 0].hist(data, bins=30, alpha=0.7)
axes[1, 0].set_title('Histogram')
# Subplot 4: Bar chart
categories = ['A', 'B', 'C', 'D']
values = [23, 45, 56, 78]
axes[1, 1].bar(categories, values)
axes[1, 1].set_title('Bar Chart')
plt.tight_layout()
plt.show()</textarea>
</div>
<!-- Seaborn Examples -->
<div class="bg-slate-700/30 rounded-lg p-4 border border-slate-600/50">
<div class="flex items-center justify-between mb-3">
<h3 class="text-lg font-medium text-emerald-300">Seaborn Examples</h3>
<button class="copy-btn px-3 py-1 bg-emerald-600 hover:bg-emerald-700 text-white text-xs rounded transition-colors duration-200 flex items-center space-x-1" data-target="seaborn-code">
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v8a2 2 0 01-2 2h-2m-6-4l2 2m0 0l2-2m-2 2V10"></path>
</svg>
<span>Copy</span>
</button>
</div>
<textarea
id="seaborn-code"
rows="15"
class="w-full px-3 py-2 bg-slate-800/50 border border-slate-600 rounded text-gray-200 font-mono text-sm resize-none"
readonly
>import seaborn as sns
import pandas as pd
import numpy as np
# Set style
sns.set_style("whitegrid")
sns.set_palette("husl")
# Load sample data
tips = sns.load_dataset("tips")
# Distribution plots
plt.figure(figsize=(12, 4))
plt.subplot(1, 3, 1)
sns.histplot(data=tips, x="total_bill", kde=True)
plt.title("Total Bill Distribution")
plt.subplot(1, 3, 2)
sns.boxplot(data=tips, x="day", y="total_bill")
plt.title("Total Bill by Day")
plt.subplot(1, 3, 3)
sns.violinplot(data=tips, x="day", y="total_bill", hue="sex")
plt.title("Total Bill by Day and Sex")
plt.tight_layout()
plt.show()
# Correlation heatmap
plt.figure(figsize=(8, 6))
numeric_data = tips.select_dtypes(include=[np.number])
correlation_matrix = numeric_data.corr()
sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm', center=0)
plt.title("Correlation Heatmap")
plt.show()
# Pair plot
sns.pairplot(tips, hue="sex", diag_kind="hist")
plt.show()</textarea>
</div>
</div>
</div>
<!-- Interactive Widgets Section -->
<div class="mb-8">
<h2 class="text-xl font-semibold text-emerald-300 mb-4">Interactive Widgets</h2>
<div class="bg-slate-700/30 rounded-lg p-4 border border-slate-600/50">
<div class="flex items-center justify-between mb-3">
<h3 class="text-lg font-medium text-emerald-300">Interactive Controls</h3>
<button class="copy-btn px-3 py-1 bg-emerald-600 hover:bg-emerald-700 text-white text-xs rounded transition-colors duration-200 flex items-center space-x-1" data-target="widgets-code">
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v8a2 2 0 01-2 2h-2m-6-4l2 2m0 0l2-2m-2 2V10"></path>
</svg>
<span>Copy</span>
</button>
</div>
<textarea
id="widgets-code"
rows="20"
class="w-full px-3 py-2 bg-slate-800/50 border border-slate-600 rounded text-gray-200 font-mono text-sm resize-none"
readonly
>import ipywidgets as widgets
from IPython.display import display
import matplotlib.pyplot as plt
import numpy as np
# Basic interactive plot
def plot_sine_wave(frequency, amplitude):
x = np.linspace(0, 4*np.pi, 1000)
y = amplitude * np.sin(frequency * x)
plt.figure(figsize=(10, 6))
plt.plot(x, y, 'b-', linewidth=2)
plt.title(f'Sine Wave: f={frequency}, A={amplitude}')
plt.xlabel('X')
plt.ylabel('Y')
plt.grid(True)
plt.show()
# Create interactive widgets
frequency_slider = widgets.FloatSlider(
value=1.0,
min=0.1,
max=5.0,
step=0.1,
description='Frequency:'
)
amplitude_slider = widgets.FloatSlider(
value=1.0,
min=0.1,
max=3.0,
step=0.1,
description='Amplitude:'
)
# Interactive widget
interactive_plot = widgets.interactive(
plot_sine_wave,
frequency=frequency_slider,
amplitude=amplitude_slider
)
display(interactive_plot)
# Dropdown and text widgets
def analyze_data(dataset, operation):
if dataset == 'Iris':
data = sns.load_dataset('iris')
elif dataset == 'Tips':
data = sns.load_dataset('tips')
else:
data = sns.load_dataset('titanic')
if operation == 'Info':
return data.info()
elif operation == 'Describe':
return data.describe()
else:
return data.head()
dataset_dropdown = widgets.Dropdown(
options=['Iris', 'Tips', 'Titanic'],
value='Iris',
description='Dataset:'
)
operation_dropdown = widgets.Dropdown(
options=['Info', 'Describe', 'Head'],
value='Info',
description='Operation:'
)
interactive_analysis = widgets.interactive(
analyze_data,
dataset=dataset_dropdown,
operation=operation_dropdown
)
display(interactive_analysis)</textarea>
</div>
</div>
<!-- Quick Reference Section -->
<div class="mt-8 p-4 bg-slate-700/30 rounded-lg border border-slate-600/50">
<h3 class="text-lg font-semibold text-emerald-400 mb-3">Quick Reference</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 text-sm">
<div>
<p class="text-gray-300 font-medium mb-2">Keyboard Shortcuts:</p>
<ul class="text-gray-400 space-y-1">
<li>• <code>Shift + Enter</code> - Run cell</li>
<li>• <code>Ctrl + Enter</code> - Run cell (stay)</li>
<li>• <code>A</code> - Insert cell above</li>
<li>• <code>B</code> - Insert cell below</li>
<li>• <code>DD</code> - Delete cell</li>
<li>• <code>M</code> - Markdown mode</li>
<li>• <code>Y</code> - Code mode</li>
</ul>
</div>
<div>
<p class="text-gray-300 font-medium mb-2">Useful Extensions:</p>
<ul class="text-gray-400 space-y-1">
<li>• <code>jupyter_contrib_nbextensions</code></li>
<li>• <code>jupyterlab-git</code> - Git integration</li>
<li>• <code>jupyterlab-lsp</code> - Language server</li>
<li>• <code>jupyterlab-drawio</code> - Diagrams</li>
<li>• <code>jupyterlab-toc</code> - Table of contents</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Sidebar Scripts -->
<!-- Include Final Sidebar -->
<div id="sidebar-container"></div>
<script>
// Load final_sidebar.html content
fetch('final_sidebar.html')
.then(response => response.text())
.then(html => {
document.getElementById('sidebar-container').innerHTML = html;
})
.catch(error => {
console.error('Error loading sidebar:', error);
});
</script>
</body>
</html>