Avoir un environnement Python fonctionnel pour la data science
Ce chapitre introduit les bases de l’environnement Python
pour la data science en mettant l’accent sur la modularité du langage et l’utilisation des notebooks…
A complete course about data science.
Lino Galiana
2025-08-22
Python
Cours de deuxième année du cursus d’ingénieur de l’ENSAE
(Master 1).
L’ensemble du contenu de ce cours est librement disponible ici
ou sur Github
et peut être testé
sous forme de notebooks Jupyter
Un cours pas-à-pas pour découvrir la data science avec , structuré en chapitres complémentaires et indépendants.
A step-by-step course to explore data science with , structured into complementary yet standalone chapters.
viewof ordre = ToggleSwitch({
labels: labels,
values: ["ordre", "vrac"],
value: "vrac",
sliderColor: quartoThemeIsDark ? "#e7c582" : "#444",
textColor: quartoThemeIsDark ? "#e7c582" : "#444"
})
initialOrdered = Array.from(document.querySelectorAll('.list-chapter-ordered'))
.map(div => div.innerHTML)
initialUnordered = Array.from(document.querySelectorAll('.list-chapter-unordered'))
.map(div => div.innerHTML)
{
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 = '');
}
}
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;
}
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);
}
`
{
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";
}
}
{
setTimeout(() => {
const giscus = document.querySelector('.giscus');
if (giscus) giscus.style.display = "none";
}, 3000); // 5000ms = 5 seconds
}
@book{galiana2023,
author = {Galiana, Lino},
title = {Python pour la data science},
date = {2023},
url = {https://pythonds.linogaliana.fr/},
doi = {10.5281/zenodo.8229676},
langid = {fr}
}