-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathindex.qmd
More file actions
427 lines (323 loc) · 11.7 KB
/
index.qmd
File metadata and controls
427 lines (323 loc) · 11.7 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
---
pagetitle: "Python pour la data science"
page-layout: custom
section-divs: false
toc: false
css: styles/homepage.css
description: |
A complete course about data science.
hide-description: true
image: https://minio.lab.sspcloud.fr/lgaliana/generative-art/pythonds/kiddos.png
listing:
id: sample-listings
contents:
- "content/getting-started/*.qmd"
- "content/manipulation/*.qmd"
- "!content/manipulation/03_geopandas_tutorial.qmd"
- "content/visualisation/*.qmd"
- "content/modelisation/*.qmd"
- "content/NLP/*.qmd"
- "content/git/*.qmd"
type: grid
sort: "number"
categories: true
echo: false
---
:::::: {.hero-banner}
::::: {.content-block .py-4}
:::: {.hero-text}
::: {.content-visible when-profile="fr"}
# Python pour la _data science_ {{< fa brands python >}} {.mt-1 .unnumbered}
## [Lino Galiana](https://github.com/linogaliana/) {.mt-1 .unnumbered}
```{=html}
<div style="text-align: right;">
<a class="github-button" href="https://github.com/linogaliana/python-datascientist" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star this website on Github">Star this website on Github</a><script async defer src="https://buttons.github.io/buttons.js"></script>
</div>
```
### Une introduction complète à [`Python` {{< fa brands python >}}](https://www.ensae.fr/courses/1425-python-pour-le-data-scientist) {-}
Cours de deuxième année du cursus d'ingénieur de l'[`ENSAE`](https://www.ensae.fr/) et de l'[`Ensai`](https://ensai.fr/) (Master 1).
L'ensemble du contenu de ce cours est librement disponible ici
ou sur [`Github`](https://github.com/linogaliana/python-datascientist)
<a href="https://github.com/linogaliana/python-datascientist" class="github"><i class="fab fa-github"></i></a> et peut être testé
sous forme de _notebooks_ [`Jupyter` {{< iconify simple-icons:jupyter >}}](https://en.wikipedia.org/wiki/Project_Jupyter).
```{=html}
<div class="lang-switch-button" style="text-align:right; margin-top:1rem; margin-bottom:1rem;">
<a href="/en/index.html" class="button-cta">
<button class="btn"><i class="fa fa-language"></i> Switch to English version
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="20" height="20" style="vertical-align: middle; margin-left: 0.5em; display: inline-block;"><mask id="circleFlagsLangEn"><circle cx="256" cy="256" r="256" fill="#fff"/></mask><g mask="url(#circleFlagsLangEn)"><path fill="#eee" d="M256 0L0 256v64l32 32l-32 32v128l22-8l23 8h23l54-32l54 32h32l48-32l48 32h32l54-32l54 32h68l-8-22l8-23v-23l-32-54l32-54v-32l-32-48l32-48v-32l-32-54l32-54V0z"/><path fill="#d80027" d="M224 64v64h160l64-64zm0 128l32 64l-48 48v208h96V304h208v-96H304l16-16zM0 320v64h128l-64 64H0v64h45l131-131v-45l16-16zm336 16l176 176v-45L381 336Z"/><path fill="#0052b4" d="M0 0v256h256V0zm512 68L404 176h108zM404 336l108 108V336zm-228 68L68 512h108zm160 0v108h108z"/><path fill="#eee" d="m187 243l57-41h-70l57 41l-22-67zm-81 0l57-41H93l57 41l-22-67zm-81 0l57-41H12l57 41l-22-67zm162-81l57-41h-70l57 41l-22-67zm-81 0l57-41H93l57 41l-22-67zm-81 0l57-41H12l57 41l-22-67Zm162-82l57-41h-70l57 41l-22-67zm-81 0l57-41H93l57 41l-22-67Zm-81 0l57-41H12l57 41l-22-67Z"/></g></svg>
</button>
</a>
</div>
```
:::
::: {.content-visible when-profile="en"}
# Python for _data science_ {{< fa brands python >}} {.mt-1 .unnumbered}
## [Lino Galiana](https://github.com/linogaliana/) {.mt-1 .unnumbered}
```{=html}
<div style="text-align: right;">
<a class="github-button" href="https://github.com/linogaliana/python-datascientist" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star this website on Github">Star this website on Github</a><script async defer src="https://buttons.github.io/buttons.js"></script>
</div>
```
### A complete introduction to [`Python` {{< fa brands python >}}](https://www.ensae.fr/courses/1425-python-pour-le-data-scientist) {-}
Second year engineering course from [`ENSAE`](https://www.ensae.fr/) (Master 1).
The entire content of this course is freely available here
or on [`Github`](https://github.com/linogaliana/python-datascientist)
<a href="https://github.com/linogaliana/python-datascientist" class="github"><i class="fab fa-github"></i></a> and can be tested
as _notebooks_ [`Jupyter` {{< iconify simple-icons:jupyter >}}](https://en.wikipedia.org/wiki/Project_Jupyter).
```{=html}
<div class="lang-switch-button" style="text-align:right; margin-top:1rem; margin-bottom:1rem;">
<a href="/index.html" class="button-cta">
<button class="btn"><i class="fa fa-language"></i> Passer à la version française
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="20" height="20" style="vertical-align: middle; margin-left: 0.5em; display: inline-block;"><mask id="circleFlagsLangFr"><circle cx="256" cy="256" r="256" fill="#fff"/></mask><g mask="url(#circleFlagsLangFr)"><path fill="#0055A4" d="M0 0h512v512H0z"/><path fill="#fff" d="M170.7 0h170.6v512H170.7z"/><path fill="#EF4135" d="M341.3 0H512v512H341.3z"/></g></svg>
</button>
</a>
</div>
```
:::
<br>
[Get Started](/content/getting-started/index.qmd){.btn-action-primary .btn-action .btn .btn-lg .w-100 role="button"}
::::
:::: {.hero-animation}

::::
:::::
::::::
:::: {.content-block .py-4}
```{ojs}
html`${viewof ordre}`
```
::: {.content-visible when-profile="fr"}
```{ojs}
labels = ["Chapitres dans l'ordre", "Chapitres en vrac"]
version_ui = "fr"
```
:::
::: {.content-visible when-profile="en"}
```{ojs}
labels = ["Chapters in order", "Chapters in mosaic"]
version_ui = "en"
```
:::
::: {.list-chapter-ordered}
```{python}
#| echo: false
%run "./build/homepage/syllabus.py"
syllabus = build_syllabus_pipeline(
"doc/syllabus.json", lang = "en"
)
```
{{< include "/content/annexes/syllabus.qmd" >}}
:::
::: {#sample-listings .list-chapter-unordered}
:::
::::
```{ojs}
//| output: false
{
const orderedDivs = document.querySelectorAll(".list-chapter-ordered");
const unorderedDivs = document.querySelectorAll(".list-chapter-unordered");
const lang = version_ui; // 'fr' ou 'en'
const otherLang = lang === "fr" ? "en" : "fr";
if (ordre === "vrac") {
unorderedDivs.forEach((div, i) => (div.innerHTML = initialUnordered[i]));
orderedDivs.forEach(div => (div.innerHTML = ""));
} else {
orderedDivs.forEach((div, i) => {
// Choisir la source HTML à injecter
const useDarkFr = (quartoThemeIsDark && lang === "fr" && initialOrderedDarkFr?.[i]);
div.innerHTML = useDarkFr ? initialOrderedDarkFr[i] : initialOrdered[i];
// Supprimer le bloc de la langue non sélectionnée (si présent)
const otherLangBlock = div.querySelector(`.list-chapter-ordered-${otherLang}`);
if (otherLangBlock) otherLangBlock.remove();
// Nettoyage: si jamais un wrapper dark-fr traîne, on le supprime
const darkFrBlock = div.querySelector(".list-chapter-ordered-dark-fr");
if (darkFrBlock) darkFrBlock.remove();
});
unorderedDivs.forEach(div => (div.innerHTML = ""));
}
}
```
```{ojs}
//| echo: false
viewof ordre = ToggleSwitch({
labels: labels,
values: ["ordre", "vrac"],
value: "vrac",
sliderColor: quartoThemeIsDark ? "#e7c582" : "#444",
textColor: quartoThemeIsDark ? "#e7c582" : "#444"
})
```
```{ojs}
// Capture `.list-chapter-unordered`
initialOrdered = Array.from(document.querySelectorAll('.list-chapter-ordered'))
.map(div => div.innerHTML)
initialUnordered = Array.from(document.querySelectorAll('.list-chapter-unordered'))
.map(div => div.innerHTML)
```
```{ojs}
//| output: false
{
const orderedDivs = document.querySelectorAll('.list-chapter-ordered');
const unorderedDivs = document.querySelectorAll('.list-chapter-unordered');
const lang = version_ui; // 'fr' ou 'en'
const otherLang = lang === 'fr' ? 'en' : 'fr';
if (ordre === 'vrac') {
unorderedDivs.forEach((div, i) => div.innerHTML = initialUnordered[i]);
orderedDivs.forEach(div => div.innerHTML = '');
} else {
orderedDivs.forEach((div, i) => {
// Restaurer le contenu initial
div.innerHTML = initialOrdered[i];
// Supprimer le bloc de la langue non sélectionnée
const otherLangBlock = div.querySelector(`.list-chapter-ordered-${otherLang}`);
if (otherLangBlock) otherLangBlock.remove();
});
// Cacher les unordered
unorderedDivs.forEach(div => div.innerHTML = '');
}
}
```
```{ojs}
viewof quartoThemeIsDark = {
const span = html`<span style="display: none;"></span>`;
function updateTheme() {
const isDark = document.body.classList.contains("quarto-dark");
span.value = isDark;
span.dispatchEvent(new CustomEvent("input"));
}
// Initial check
updateTheme();
// Observer les changements de classe sur <body>
const observer = new MutationObserver(() => updateTheme());
observer.observe(document.body, {
attributes: true,
attributeFilter: ["class"]
});
// Nettoyage si jamais nécessaire
span.remove = () => observer.disconnect();
return span;
}
```
```{ojs}
//| echo: false
ToggleSwitch = ({
labels = ["Gauche", "Droite"],
values = ["left", "right"],
value = values[0],
sliderColor = "#275EFE",
textColor = "#444"
} = {}) => {
const [labelLeft, labelRight] = labels;
const [valLeft, valRight] = values;
const node = html`<div class="toggle-wrapper"
style="--slider-color: ${sliderColor}; --text-color: ${textColor}">
<span class="label left">${labelLeft}</span>
<label class="toggle-ios">
<input type="checkbox" ${value === valRight ? "checked" : ""}>
<span class="slider"></span>
</label>
<span class="label right">${labelRight}</span>
<style>
${styleOptions}
</style>
</div>`;
const input = node.querySelector("input");
const updateLabels = () => {
node.querySelector(".label.left").classList.toggle("active", !input.checked);
node.querySelector(".label.right").classList.toggle("active", input.checked);
};
Object.defineProperty(node, "value", {
get: () => (input.checked ? valRight : valLeft),
set: (v) => {
input.checked = (v === valRight);
updateLabels();
}
});
input.addEventListener("change", () => {
updateLabels();
node.dispatchEvent(new CustomEvent("input"));
});
updateLabels();
return node;
}
styleOptions = `
.toggle-wrapper {
display: flex;
align-items: center;
gap: 0.5rem;
font-family: sans-serif;
font-size: 14px;
color: var(--text-color);
}
.label {
transition: font-weight 0.2s;
}
.label.active {
font-weight: bold;
}
.toggle-ios {
position: relative;
display: inline-block;
width: 44px;
height: 24px;
}
.toggle-ios input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
transition: 0.3s;
border-radius: 34px;
}
.slider:before {
position: absolute;
content: "";
height: 18px;
width: 18px;
left: 3px;
top: 3px;
background-color: white;
transition: 0.3s;
border-radius: 50%;
}
input:checked + .slider {
background-color: var(--slider-color);
}
input:checked + .slider:before {
transform: translateX(20px);
}
`
```
```{ojs}
//| output: false
{
const appendix = document.querySelector('#quarto-appendix');
if (appendix) {
const wrapper = document.createElement('div');
wrapper.className = 'content-block py-4';
wrapper.innerHTML = appendix.innerHTML;
// Optional: replace the original appendix in the DOM
appendix.replaceWith(wrapper);
wrapper;
} else {
"appendix not found";
}
}
```
```{ojs}
//| output: false
{
setTimeout(() => {
const giscus = document.querySelector('.giscus');
if (giscus) giscus.style.display = "none";
}, 3000); // 5000ms = 5 seconds
}
```