diff --git a/.github/workflows/notebooks.yml b/.github/workflows/notebooks.yml index 06bdbe5d3..7f1cd179a 100644 --- a/.github/workflows/notebooks.yml +++ b/.github/workflows/notebooks.yml @@ -24,7 +24,7 @@ jobs: conda list - name: Convert in ipynb with Quarto run: | - find content/course -type f -name "*.qmd" >> diff + find content -type f -name "*.qmd" >> diff cat diff python build/tweak_project.py python build/tweak_render.py diff --git a/404.qmd b/404.qmd index 7083c462d..23103070e 100644 --- a/404.qmd +++ b/404.qmd @@ -2,7 +2,7 @@ title: Page Not Found listing: id: sample-listings - contents: content/course/**/index.qmd + contents: content/**/index.qmd type: grid sort: "number" categories: true diff --git a/_quarto.yml b/_quarto.yml index 77d5de1e5..b5d6c5548 100644 --- a/_quarto.yml +++ b/_quarto.yml @@ -4,10 +4,7 @@ project: render: - index.qmd - content/**/*.qmd - - content/**/**/*.qmd - - content/**/**/**/*.qmd - - content/**/**/**/**/*.qmd - - "!content/slides/intro/index.qmd" + - "!content/slides/" book: title: "Python pour la data science" @@ -16,21 +13,21 @@ book: left: - href: index.qmd text: Home - - href: content/course/getting-started/index.qmd + - href: content/getting-started/index.qmd text: Introduction - - href: content/course/manipulation/index.qmd + - href: content/manipulation/index.qmd text: Manipuler des données - - href: content/course/visualisation/index.qmd + - href: content/visualisation/index.qmd text: Visualiser des données - - href: content/course/modelisation/index.qmd + - href: content/modelisation/index.qmd text: Modéliser - - href: content/course/NLP/index.qmd + - href: content/NLP/index.qmd text: NLP - - href: content/course/modern-ds/index.qmd + - href: content/modern-ds/index.qmd text: Approfondissements - - href: content/course/git/index.qmd + - href: content/git/index.qmd text: Git {{< fa brands git-alt >}} - - href: content/course/annexes/evaluation/index.qmd + - href: content/annexes/evaluation.qmd text: Evaluation tools: - icon: github @@ -60,62 +57,62 @@ book: chapters: - href: index.qmd text: "Homepage" - - part: "content/course/getting-started/index.qmd" + - part: "content/getting-started/index.qmd" chapters: - - content/course/getting-started/01_installation/index.qmd - - content/course/getting-started/02_DS_environment/index.qmd - - content/course/getting-started/03_data_analysis/index.qmd - - content/course/getting-started/04_python_practice/index.qmd - - content/course/getting-started/05_rappels_types/index.qmd - - content/course/getting-started/06_rappels_fonctions/index.qmd - - content/course/getting-started/07_rappels_classes/index.qmd - - part: content/course/manipulation/index.qmd + - content/getting-started/01_installation.qmd + - content/getting-started/02_DS_environment.qmd + - content/getting-started/03_data_analysis.qmd + - content/getting-started/04_python_practice.qmd + - content/getting-started/05_rappels_types.qmd + - content/getting-started/06_rappels_fonctions.qmd + - content/getting-started/07_rappels_classes.qmd + - part: content/manipulation/index.qmd chapters: - - content/course/manipulation/01_numpy/index.qmd - - content/course/manipulation/02a_pandas_tutorial/index.qmd - - content/course/manipulation/02b_pandas_TP/index.qmd - - content/course/manipulation/03_geopandas_tutorial/index.qmd - - content/course/manipulation/03_geopandas_TP/index.qmd - - content/course/manipulation/04a_webscraping_TP/index.qmd - - content/course/manipulation/04c_API_TP/index.qmd - - content/course/manipulation/04b_regex_TP/index.qmd - - content/course/manipulation/07_dask/index.qmd - - content/course/manipulation/06a_exo_supp_webscraping/index.qmd - - part: content/course/visualisation/index.qmd + - content/manipulation/01_numpy.qmd + - content/manipulation/02a_pandas_tutorial.qmd + - content/manipulation/02b_pandas_TP.qmd + - content/manipulation/03_geopandas_tutorial.qmd + - content/manipulation/03_geopandas_TP.qmd + - content/manipulation/04a_webscraping_TP.qmd + - content/manipulation/04c_API_TP.qmd + - content/manipulation/04b_regex_TP.qmd + - content/manipulation/07_dask.qmd + - content/manipulation/06a_exo_supp_webscraping.qmd + - part: content/visualisation/index.qmd chapters: - - content/course/visualisation/matplotlib/index.qmd - - content/course/visualisation/maps/index.qmd - - part: content/course/modelisation/index.qmd + - content/visualisation/matplotlib.qmd + - content/visualisation/maps.qmd + - part: content/modelisation/index.qmd chapters: - - content/course/modelisation/0_preprocessing/index.qmd - - content/course/modelisation/1_modelevaluation/index.qmd - - content/course/modelisation/2_SVM/index.qmd - - content/course/modelisation/3_regression/index.qmd - - content/course/modelisation/4_featureselection/index.qmd - - content/course/modelisation/5_clustering/index.qmd - - content/course/modelisation/6_pipeline/index.qmd - - part: content/course/NLP/index.qmd + - content/modelisation/0_preprocessing.qmd + - content/modelisation/1_modelevaluation.qmd + - content/modelisation/2_SVM.qmd + - content/modelisation/3_regression.qmd + - content/modelisation/4_featureselection.qmd + - content/modelisation/5_clustering.qmd + - content/modelisation/6_pipeline.qmd + - part: content/NLP/index.qmd chapters: - - content/course/NLP/01_intro/index.qmd - - content/course/NLP/02_exoclean/index.qmd - - content/course/NLP/03_lda/index.qmd - - content/course/NLP/04_word2vec/index.qmd - - content/course/NLP/05_exo_supp/index.qmd - - part: content/course/modern-ds/index.qmd + - content/NLP/01_intro.qmd + - content/NLP/02_exoclean.qmd + - content/NLP/03_lda.qmd + - content/NLP/04_word2vec.qmd + - content/NLP/05_exo_supp.qmd + - part: content/modern-ds/index.qmd chapters: - - content/course/modern-ds/continuous_integration/index.qmd - - content/course/modern-ds/dallE/index.qmd - - content/course/modern-ds/s3/index.qmd - - content/course/modern-ds/elastic_approfondissement/index.qmd - - content/course/modern-ds/elastic_intro/index.qmd - - part: content/course/git/index.qmd + - content/modern-ds/continuous_integration.qmd + - content/modern-ds/dallE.qmd + - content/modern-ds/s3.qmd + - content/modern-ds/elastic_approfondissement.qmd + - content/modern-ds/elastic_intro/index.qmd + - part: content/git/index.qmd chapters: - - content/course/git/introgit/index.qmd - - content/course/git/exogit/index.qmd - - part: content/course/annexes/index.qmd + - content/git/introgit.qmd + - content/git/exogit.qmd + - part: content/annexes/index.qmd chapters: - - content/course/annexes/evaluation/index.qmd - - content/course/corrections/index.qmd + - content/annexes/evaluation.qmd + - content/annexes/corrections.qmd filters: - lightbox diff --git a/build/cleanmd.py b/build/cleanmd.py deleted file mode 100755 index e7a2027c0..000000000 --- a/build/cleanmd.py +++ /dev/null @@ -1,14 +0,0 @@ -import functions as fc - -# shell -#cd "temp/course/NLP" -#jupytext --to ipynb "02_exoclean.Rmd" -#jupytext --to ipynb "02_exoclean.Rmd" --execute - -# TATONNEMENT ------ - - -#os.chdir("./temp/content") -#cleanfile('course/NLP/02_exoclean.Rmd', None, True) - -fc.cleanblog() diff --git a/build/featured.py b/build/featured.py deleted file mode 100644 index cdd52157f..000000000 --- a/build/featured.py +++ /dev/null @@ -1,37 +0,0 @@ -import yaml -import os -import shutil -import glob -import imageio.v2 as imageio - - -from PIL import Image - -#os.chdir("python-datascientist/") - -with open(r'featured.yaml') as file: - dict_featured = yaml.full_load(file) - -req_width = 918 -req_height = 517 - -locations = list(dict_featured.keys()) -location=locations[0] - -def resize_write_image(dict_featured, location): - loc = dict_featured[location] - loc = f"./content/course/{location}/{loc}" - shutil.copy2(loc, os.path.dirname(loc) + "/featured.png") - - -list_images = glob.glob("./content/course/**/**/featured.png") -list_images = ["./content/home/word.png"] + list_images -with imageio.get_writer('animation.gif', mode='I', fps = 1) as writer: - for filename in list_images: - image = imageio.imread(filename) - writer.append_data(image) - - -#img = Image.open(loc) -#img = img.resize((req_width,req_height), Image.ANTIALIAS) -#img.save(os.path.dirname(loc) + "/featured.png") \ No newline at end of file diff --git a/build/modifmd.py b/build/modifmd.py deleted file mode 100644 index 2e553a362..000000000 --- a/build/modifmd.py +++ /dev/null @@ -1,4 +0,0 @@ -import functions as fc - -fc.cleanblog(type = "Rmd") - diff --git a/build/post-build.py b/build/post-build.py deleted file mode 100644 index 2149af166..000000000 --- a/build/post-build.py +++ /dev/null @@ -1,35 +0,0 @@ -import glob -import re -def read_file(filename): - with open(filename, 'r', encoding='utf-8') as f: - text = f.readlines() - f.close() - new_text = " ".join([line for line in text]) - s = new_text - return s - -def replace_shortcode_tabs(content): - content = content.replace("\<", "<") - content = content.replace("\>", ">") - return content - -def tweak_js_plotly(content): - content2 = re.sub( - r'\n', - '', - content) - return content2 - - -def write_file(filename, content): - with open(filename, 'w') as f: - f.write(content) - -def clean_write_file(fl): - content = read_file(fl) - if not fl.endswith("_index.md"): - content = replace_shortcode_tabs(content) - write_file(fl, content) - -list_files = glob.glob("./content/**/*.md", recursive=True) -[clean_write_file(fl) for fl in list_files] diff --git a/build/tweak_markdown.py b/build/tweak_markdown.py index 442560ae1..26270e9a6 100644 --- a/build/tweak_markdown.py +++ b/build/tweak_markdown.py @@ -9,48 +9,7 @@ def read_file(filename): s = new_text return s -def replace_shortcode_tabs(content): - content = content.replace("\<", "<") - content = content.replace("\>", ">") - return content - -def tweak_js_plotly(content): - content2 = re.sub( - r'\n', - '', - content) - return content2 - - def write_file(filename, content): with open(filename, 'w', encoding="utf-8") as f: f.write(content) -def clean_write_file(fl): - content = read_file(fl) - content = re.sub(r"(“|”)",'"',content) - print(f"File: {fl}") - add_text = '\n\n\n' - yaml, text = content.split('---\n', 2)[1:] - incipit = "Ce contenu accompagne le cours [Python pour la data science](https://pythonds.linogaliana.fr/) de l'ENSAE. \n" - if re.search("plotly: true", yaml) is not None: - print(f"Tweaking {fl} using YAML header") - content = "---\n" + yaml + "---\n" \ - + "\n" + incipit + add_text + "\n" + text - else: - print(f"File {fl}: nothing to do") - if re.search( - r'\n', - content) is not None: - print("quarto added plotly detected: removed") - content = tweak_js_plotly(content) - write_file(fl, content) - - -if __name__ == '__main__': - list_files = glob.glob("./content/course/**/index.md", recursive=True) - print(list_files) - [clean_write_file(fl) for fl in list_files if not fl.endswith("_index.md")] - - - diff --git a/build/tweak_render.py b/build/tweak_render.py index 958195771..14e60549b 100644 --- a/build/tweak_render.py +++ b/build/tweak_render.py @@ -14,14 +14,17 @@ lines = glob.glob('content/**/*.qmd', recursive=True) lines = [l for l in lines if l.endswith('.qmd') ] -lines += [f"content/course/{dir}/index.qmd" \ - for dir in ["manipulation", "visualisation", "modelisation", "NLP", "modern-ds"] +lines += [f"content/{dir}/index.qmd" \ + for dir in [ + "getting-started", "manipulation", + "visualisation", "modelisation", + "NLP", "modern-ds"] ] lines += [f"index.qmd"] config.setdefault('book', {})['chapters'] = lines -lines2 = lines + ["!content/slides/intro/index.qmd"] +lines2 = lines + ["!content/slides/"] print(lines2) diff --git a/content/course/NLP/01_intro/index.qmd b/content/NLP/01_intro.qmd similarity index 98% rename from content/course/NLP/01_intro/index.qmd rename to content/NLP/01_intro.qmd index 58026b61b..37299849c 100644 --- a/content/course/NLP/01_intro/index.qmd +++ b/content/NLP/01_intro.qmd @@ -30,11 +30,11 @@ image: wordcloud_openfood_clean.png #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/NLP/01_intro.qmd") +print_badges("content/NLP/01_intro.qmd") ``` ::: @@ -150,7 +150,7 @@ import requests import PIL import matplotlib.pyplot as plt -img = "https://raw.githubusercontent.com/linogaliana/python-datascientist/master/content/course/NLP/book.png" +img = "https://raw.githubusercontent.com/linogaliana/python-datascientist/master/content/NLP/book.png" book_mask = np.array(PIL.Image.open(io.BytesIO(requests.get(img).content))) fig = plt.figure() diff --git a/content/course/NLP/02_exoclean/index.qmd b/content/NLP/02_exoclean.qmd similarity index 99% rename from content/course/NLP/02_exoclean/index.qmd rename to content/NLP/02_exoclean.qmd index 7b6d557ea..6d35f586e 100644 --- a/content/course/NLP/02_exoclean/index.qmd +++ b/content/NLP/02_exoclean.qmd @@ -33,11 +33,11 @@ image: featured.png #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/NLP/02_exoclean.qmd") +print_badges("content/NLP/02_exoclean.qmd") ``` ::: @@ -231,7 +231,7 @@ Si vous ne faites pas l'exercice 1, pensez à charger les données en executant ```{python} import requests -url = 'https://raw.githubusercontent.com/linogaliana/python-datascientist/master/content/course/NLP/get_data.py' +url = 'https://raw.githubusercontent.com/linogaliana/python-datascientist/master/content/NLP/get_data.py' r = requests.get(url, allow_redirects=True) open('getdata.py', 'wb').write(r.content) diff --git a/content/course/NLP/03_lda/index.qmd b/content/NLP/03_lda.qmd similarity index 99% rename from content/course/NLP/03_lda/index.qmd rename to content/NLP/03_lda.qmd index 15554d494..d282b5b46 100644 --- a/content/course/NLP/03_lda/index.qmd +++ b/content/NLP/03_lda.qmd @@ -32,11 +32,11 @@ image: https://upload.wikimedia.org/wikipedia/commons/thumb/d/d3/Latent_Dirichle #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/NLP/03_lda.qmd") +print_badges("content/NLP/03_lda.qmd") ``` ::: diff --git a/content/course/NLP/04_word2vec/index.qmd b/content/NLP/04_word2vec.qmd similarity index 99% rename from content/course/NLP/04_word2vec/index.qmd rename to content/NLP/04_word2vec.qmd index 3df5d84af..484c24ec5 100644 --- a/content/course/NLP/04_word2vec/index.qmd +++ b/content/NLP/04_word2vec.qmd @@ -23,7 +23,7 @@ description: | permet d'exploiter les structures latentes d'un texte en construisant des _word embeddings_ (plongements de mots). eval: false -image: featured.png +image: featured_intro.png --- ::: {.cell .markdown} @@ -34,11 +34,11 @@ image: featured.png #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/NLP/04_word2vec.qmd") +print_badges("content/NLP/04_word2vec.qmd") ``` ::: diff --git a/content/course/NLP/05_exo_supp/index.qmd b/content/NLP/05_exo_supp.qmd similarity index 98% rename from content/course/NLP/05_exo_supp/index.qmd rename to content/NLP/05_exo_supp.qmd index eae7e6d22..0b91f43c6 100644 --- a/content/course/NLP/05_exo_supp/index.qmd +++ b/content/NLP/05_exo_supp.qmd @@ -17,7 +17,7 @@ categories: description: | Des exercices supplémentaires pour pratiquer les concepts du NLP eval: false -image: featured.png +image: featured_intro.png --- ::: {.cell .markdown} @@ -28,11 +28,11 @@ image: featured.png #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/NLP/05_exo_supp.qmd") +print_badges("content/NLP/05_exo_supp.qmd") ``` ::: diff --git a/content/course/NLP/get_data.py b/content/NLP/get_data.py similarity index 100% rename from content/course/NLP/get_data.py rename to content/NLP/get_data.py diff --git a/content/course/NLP/index.qmd b/content/NLP/index.qmd similarity index 100% rename from content/course/NLP/index.qmd rename to content/NLP/index.qmd diff --git a/content/course/corrections/index.qmd b/content/annexes/corrections.qmd similarity index 66% rename from content/course/corrections/index.qmd rename to content/annexes/corrections.qmd index e409b79c7..2bfe1342d 100644 --- a/content/course/corrections/index.qmd +++ b/content/annexes/corrections.qmd @@ -30,7 +30,7 @@ Retour sur `numpy` #| output: 'asis' #| include: true #| eval: true -print_badges("content/course/manipulation/01_numpy.qmd", correction=True) +print_badges("content/manipulation/01_numpy.qmd", correction=True) ``` ::: @@ -42,7 +42,7 @@ Exercices `pandas`: #| output: 'asis' #| include: true #| eval: true -print_badges("content/course/manipulation/02b_pandas_TP.qmd", correction=True) +print_badges("content/manipulation/02b_pandas_TP.qmd", correction=True) ``` ::: @@ -54,7 +54,7 @@ Exercices `geopandas`: #| output: 'asis' #| include: true #| eval: true -print_badges("content/course/manipulation/03_geopandas_TP.qmd", correction=True) +print_badges("content/manipulation/03_geopandas_TP.qmd", correction=True) ``` ::: @@ -66,7 +66,7 @@ Webscraping #| output: 'asis' #| include: true #| eval: true -print_badges("content/course/manipulation/04a_webscraping_TP.qmd", correction=True) +print_badges("content/manipulation/04a_webscraping_TP.qmd", correction=True) ``` ::: @@ -78,7 +78,7 @@ Expressions régulières: #| output: 'asis' #| include: true #| eval: true -print_badges("content/course/manipulation/04b_regex_TP.qmd", correction=True) +print_badges("content/manipulation/04b_regex_TP.qmd", correction=True) ``` ::: @@ -88,7 +88,7 @@ print_badges("content/course/manipulation/04b_regex_TP.qmd", correction=True) #| output: 'asis' #| include: true #| eval: true -print_badges("content/course/manipulation/04c_API_TP.qmd", correction=True) +print_badges("content/manipulation/04c_API_TP.qmd", correction=True) ``` ::: @@ -101,7 +101,7 @@ print_badges("content/course/manipulation/04c_API_TP.qmd", correction=True) #| output: 'asis' #| include: true #| eval: true -print_badges("content/course/visualisation/matplotlib.qmd", correction=True) +print_badges("content/visualisation/matplotlib.qmd", correction=True) ``` ::: @@ -111,7 +111,7 @@ print_badges("content/course/visualisation/matplotlib.qmd", correction=True) #| output: 'asis' #| include: true #| eval: true -print_badges("content/course/visualisation/maps.qmd", correction=True) +print_badges("content/visualisation/maps.qmd", correction=True) ``` ::: @@ -124,7 +124,7 @@ print_badges("content/course/visualisation/maps.qmd", correction=True) #| output: 'asis' #| include: true #| eval: true -print_badges("content/course/modelisation/0_preprocessing.qmd", correction=True) +print_badges("content/modelisation/0_preprocessing.qmd", correction=True) ``` ::: @@ -134,7 +134,7 @@ print_badges("content/course/modelisation/0_preprocessing.qmd", correction=True) #| output: 'asis' #| include: true #| eval: true -print_badges("content/course/modelisation/1_modelevaluation.qmd", correction=True) +print_badges("content/modelisation/1_modelevaluation.qmd", correction=True) ``` ::: @@ -144,7 +144,7 @@ print_badges("content/course/modelisation/1_modelevaluation.qmd", correction=Tru #| output: 'asis' #| include: true #| eval: true -print_badges("content/course/modelisation/2_SVM.qmd", correction=True) +print_badges("content/modelisation/2_SVM.qmd", correction=True) ``` ::: @@ -154,7 +154,7 @@ print_badges("content/course/modelisation/2_SVM.qmd", correction=True) #| output: 'asis' #| include: true #| eval: true -print_badges("content/course/modelisation/3_regression.qmd", correction=True) +print_badges("content/modelisation/3_regression.qmd", correction=True) ``` ::: @@ -164,7 +164,7 @@ print_badges("content/course/modelisation/3_regression.qmd", correction=True) #| output: 'asis' #| include: true #| eval: true -print_badges("content/course/modelisation/4_featureselection.qmd", correction=True) +print_badges("content/modelisation/4_featureselection.qmd", correction=True) ``` ::: @@ -174,7 +174,7 @@ print_badges("content/course/modelisation/4_featureselection.qmd", correction=Tr #| output: 'asis' #| include: true #| eval: true -print_badges("content/course/modelisation/5_clustering.qmd", correction=True) +print_badges("content/modelisation/5_clustering.qmd", correction=True) ``` ::: @@ -184,7 +184,7 @@ print_badges("content/course/modelisation/5_clustering.qmd", correction=True) #| output: 'asis' #| include: true #| eval: true -print_badges("content/course/modelisation/6_pipeline.qmd", correction=True) +print_badges("content/modelisation/6_pipeline.qmd", correction=True) ``` ::: @@ -196,7 +196,7 @@ print_badges("content/course/modelisation/6_pipeline.qmd", correction=True) #| output: 'asis' #| include: true #| eval: true -print_badges("content/course/NLP/01_intro.qmd", correction=True) +print_badges("content/NLP/01_intro.qmd", correction=True) ``` ::: @@ -206,7 +206,7 @@ print_badges("content/course/NLP/01_intro.qmd", correction=True) #| output: 'asis' #| include: true #| eval: true -print_badges("content/course/NLP/02_exoclean.qmd", correction=True) +print_badges("content/NLP/02_exoclean.qmd", correction=True) ``` ::: @@ -216,7 +216,7 @@ print_badges("content/course/NLP/02_exoclean.qmd", correction=True) #| output: 'asis' #| include: true #| eval: true -print_badges("content/course/NLP/03_lda.qmd", correction=True) +print_badges("content/NLP/03_lda.qmd", correction=True) ``` ::: @@ -226,7 +226,7 @@ print_badges("content/course/NLP/03_lda.qmd", correction=True) #| output: 'asis' #| include: true #| eval: true -print_badges("content/course/NLP/04_word2vec.qmd", correction=True) +print_badges("content/NLP/04_word2vec.qmd", correction=True) ``` ::: @@ -237,7 +237,7 @@ print_badges("content/course/NLP/04_word2vec.qmd", correction=True) #| output: 'asis' #| include: true #| eval: true -print_badges("content/course/NLP/05_exo_supp.qmd", correction=True) +print_badges("content/NLP/05_exo_supp.qmd", correction=True) ``` ::: diff --git a/content/course/annexes/evaluation/index.qmd b/content/annexes/evaluation.qmd similarity index 100% rename from content/course/annexes/evaluation/index.qmd rename to content/annexes/evaluation.qmd diff --git a/content/course/modelisation/0_preprocessing/getdata.py b/content/course/modelisation/0_preprocessing/getdata.py deleted file mode 100644 index 2404a9698..000000000 --- a/content/course/modelisation/0_preprocessing/getdata.py +++ /dev/null @@ -1,65 +0,0 @@ -import urllib -import urllib.request -import os -import zipfile -from urllib.request import Request, urlopen -from pathlib import Path -import numpy as np -import pandas as pd -import geopandas as gpd - -def download_url(url, save_path): - with urllib.request.urlopen(url) as dl_file: - with open(save_path, 'wb') as out_file: - out_file.write(dl_file.read()) - - -def create_votes_dataframes(): - - Path("data").mkdir(parents=True, exist_ok=True) - - - download_url("https://www2.census.gov/geo/tiger/GENZ2019/shp/cb_2019_us_county_20m.zip", "data/shapefile") - with zipfile.ZipFile("data/shapefile", 'r') as zip_ref: - zip_ref.extractall("data/counties") - - shp = gpd.read_file("data/counties/cb_2019_us_county_20m.shp") - shp = shp[~shp["STATEFP"].isin(["02", "69", "66", "78", "60", "72", "15"])] - shp - - df_election = pd.read_csv("https://raw.githubusercontent.com/tonmcg/US_County_Level_Election_Results_08-20/master/2020_US_County_Level_Presidential_Results.csv") - df_election.head(2) - population = pd.read_excel("https://www.ers.usda.gov/webdocs/DataFiles/48747/PopulationEstimates.xls?v=290.4", header = 2).rename(columns = {"FIPStxt": "FIPS"}) - education = pd.read_excel("https://www.ers.usda.gov/webdocs/DataFiles/48747/Education.xls?v=290.4", header = 4).rename(columns = {"FIPS Code": "FIPS", "Area name": "Area_Name"}) - unemployment = pd.read_excel("https://www.ers.usda.gov/webdocs/DataFiles/48747/Unemployment.xls?v=290.4", header = 4).rename(columns = {"fips_txt": "FIPS", "area_name": "Area_Name", "Stabr": "State"}) - income = pd.read_excel("https://www.ers.usda.gov/webdocs/DataFiles/48747/PovertyEstimates.xls?v=290.4", header = 4).rename(columns = {"FIPStxt": "FIPS", "Stabr": "State", "Area_name": "Area_Name"}) - - - dfs = [df.set_index(['FIPS', 'State']) for df in [population, education, unemployment, income]] - data_county = pd.concat(dfs, axis=1) - df_election = df_election.merge(data_county.reset_index(), left_on = "county_fips", right_on = "FIPS") - df_election['county_fips'] = df_election['county_fips'].astype(str).str.lstrip('0') - shp['FIPS'] = shp['GEOID'].astype(str).str.lstrip('0') - votes = shp.merge(df_election, left_on = "FIPS", right_on = "county_fips") - - req = Request('https://dataverse.harvard.edu/api/access/datafile/3641280?gbrecs=false') - req.add_header('User-Agent', 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:77.0) Gecko/20100101 Firefox/77.0') - content = urlopen(req) - df_historical = pd.read_csv(content, sep = "\t") - #df_historical = pd.read_csv('https://dataverse.harvard.edu/api/access/datafile/3641280?gbrecs=false', sep = "\t") - - df_historical = df_historical.dropna(subset = ["FIPS"]) - df_historical["FIPS"] = df_historical["FIPS"].astype(int) - df_historical['share'] = df_historical['candidatevotes']/df_historical['totalvotes'] - df_historical = df_historical[["year", "FIPS", "party", "candidatevotes", "share"]] - df_historical['party'] = df_historical['party'].fillna("other") - - df_historical_wide = df_historical.pivot_table(index = "FIPS", values=['candidatevotes',"share"], columns = ["year","party"]) - df_historical_wide.columns = ["_".join(map(str, s)) for s in df_historical_wide.columns.values] - df_historical_wide = df_historical_wide.reset_index() - df_historical_wide['FIPS'] = df_historical_wide['FIPS'].astype(str).str.lstrip('0') - votes['FIPS'] = votes['GEOID'].astype(str).str.lstrip('0') - votes = votes.merge(df_historical_wide, on = "FIPS") - votes["winner"] = np.where(votes['votes_gop'] > votes['votes_dem'], 'republican', 'democrats') - - return votes diff --git a/content/course/getting-started/01_installation/index.qmd b/content/getting-started/01_installation.qmd similarity index 99% rename from content/course/getting-started/01_installation/index.qmd rename to content/getting-started/01_installation.qmd index f9967387e..c0301d4cc 100644 --- a/content/course/getting-started/01_installation/index.qmd +++ b/content/getting-started/01_installation.qmd @@ -48,11 +48,11 @@ les badges suivants sont proposés: #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/manipulation/01_numpy.qmd") +print_badges("content/manipulation/01_numpy.qmd") ``` ::: diff --git a/content/course/getting-started/02_DS_environment/index.qmd b/content/getting-started/02_DS_environment.qmd similarity index 100% rename from content/course/getting-started/02_DS_environment/index.qmd rename to content/getting-started/02_DS_environment.qmd diff --git a/content/course/getting-started/03_data_analysis/index.qmd b/content/getting-started/03_data_analysis.qmd similarity index 100% rename from content/course/getting-started/03_data_analysis/index.qmd rename to content/getting-started/03_data_analysis.qmd diff --git a/content/course/getting-started/04_python_practice/index.qmd b/content/getting-started/04_python_practice.qmd similarity index 100% rename from content/course/getting-started/04_python_practice/index.qmd rename to content/getting-started/04_python_practice.qmd diff --git a/content/course/getting-started/05_rappels_types/index.qmd b/content/getting-started/05_rappels_types.qmd similarity index 99% rename from content/course/getting-started/05_rappels_types/index.qmd rename to content/getting-started/05_rappels_types.qmd index 114c27356..abf7e1661 100644 --- a/content/course/getting-started/05_rappels_types/index.qmd +++ b/content/getting-started/05_rappels_types.qmd @@ -22,11 +22,11 @@ categories: #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/getting-started/05_rappels_types.qmd") +print_badges("content/getting-started/05_rappels_types.qmd") ``` ::: diff --git a/content/course/getting-started/06_rappels_fonctions/index.qmd b/content/getting-started/06_rappels_fonctions.qmd similarity index 99% rename from content/course/getting-started/06_rappels_fonctions/index.qmd rename to content/getting-started/06_rappels_fonctions.qmd index 113f34c34..e5e15c907 100644 --- a/content/course/getting-started/06_rappels_fonctions/index.qmd +++ b/content/getting-started/06_rappels_fonctions.qmd @@ -31,11 +31,11 @@ categories: #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/getting-started/06_rappels_fonctions.qmd") +print_badges("content/getting-started/06_rappels_fonctions.qmd") ``` ::: diff --git a/content/course/getting-started/07_rappels_classes/index.qmd b/content/getting-started/07_rappels_classes.qmd similarity index 99% rename from content/course/getting-started/07_rappels_classes/index.qmd rename to content/getting-started/07_rappels_classes.qmd index f4b2d05f4..783f29bee 100644 --- a/content/course/getting-started/07_rappels_classes/index.qmd +++ b/content/getting-started/07_rappels_classes.qmd @@ -31,11 +31,11 @@ categories: #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/getting-started/07_rappels_classes.qmd") +print_badges("content/getting-started/07_rappels_classes.qmd") ``` ::: diff --git a/content/course/getting-started/index.qmd b/content/getting-started/index.qmd similarity index 99% rename from content/course/getting-started/index.qmd rename to content/getting-started/index.qmd index 81fd92f31..b83040ba9 100644 --- a/content/course/getting-started/index.qmd +++ b/content/getting-started/index.qmd @@ -261,7 +261,7 @@ sys.path.insert(1, '../../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/manipulation/01_numpy.qmd") +print_badges("content/manipulation/01_numpy.qmd") ``` Pour les agents de la fonction publique, ou diff --git a/content/course/git/exogit/index.qmd b/content/git/exogit.qmd similarity index 99% rename from content/course/git/exogit/index.qmd rename to content/git/exogit.qmd index 9854cb122..c44ee7754 100644 --- a/content/course/git/exogit/index.qmd +++ b/content/git/exogit.qmd @@ -26,11 +26,11 @@ image: https://ensae-reproductibilite.github.io/website/cards/git/snakedolls.jpg #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/git/exogit.qmd") +print_badges("content/git/exogit.qmd") ``` ::: diff --git a/content/course/git/index.qmd b/content/git/index.qmd similarity index 100% rename from content/course/git/index.qmd rename to content/git/index.qmd diff --git a/content/course/git/introgit/index.qmd b/content/git/introgit.qmd similarity index 99% rename from content/course/git/introgit/index.qmd rename to content/git/introgit.qmd index 5ee277e93..48eb45351 100644 --- a/content/course/git/introgit/index.qmd +++ b/content/git/introgit.qmd @@ -29,11 +29,11 @@ image: https://ensae-reproductibilite.github.io/website/cards/git/snakedolls.jpg #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/git/introgit.qmd") +print_badges("content/git/introgit.qmd") ``` ::: diff --git a/content/course/manipulation/01_numpy/index.qmd b/content/manipulation/01_numpy.qmd similarity index 99% rename from content/course/manipulation/01_numpy/index.qmd rename to content/manipulation/01_numpy.qmd index 1577c140d..5d61c5058 100644 --- a/content/course/manipulation/01_numpy/index.qmd +++ b/content/manipulation/01_numpy.qmd @@ -31,11 +31,11 @@ Pour essayer les exemples présents dans ce tutoriel : #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/manipulation/01_numpy.qmd") +print_badges("content/manipulation/01_numpy.qmd") ``` ::: diff --git a/content/course/manipulation/02a_pandas_tutorial/index.qmd b/content/manipulation/02a_pandas_tutorial.qmd similarity index 98% rename from content/course/manipulation/02a_pandas_tutorial/index.qmd rename to content/manipulation/02a_pandas_tutorial.qmd index dea8e7a85..111638b37 100644 --- a/content/course/manipulation/02a_pandas_tutorial/index.qmd +++ b/content/manipulation/02a_pandas_tutorial.qmd @@ -35,10 +35,10 @@ Pour essayer les exemples présents dans ce tutoriel : #| include: true #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/manipulation/02a_pandas_tutorial.qmd") +print_badges("content/manipulation/02a_pandas_tutorial.qmd") ``` ::: @@ -69,7 +69,7 @@ disponible sur [data.gouv](https://www.data.gouv.fr/fr/datasets/inventaire-de-ga et requêtable directement dans `Python` avec [cet url](https://koumoul.com/s/data-fair/api/v1/datasets/igt-pouvoir-de-rechauffement-global/convert) -Le [chapitre suivant](content/course/manipulation/02b_pandas_TP) permettra de mettre en application des éléments présents dans ce chapitre avec +Le [chapitre suivant](02b_pandas_TP) permettra de mettre en application des éléments présents dans ce chapitre avec les données ci-dessus associées à des données de contexte au niveau communal[^1]. @@ -293,11 +293,11 @@ pouvez expérimenter dans les TP #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/manipulation/02b_pandas_TP.qmd") +print_badges("content/manipulation/02b_pandas_TP.qmd") ``` ::: @@ -410,11 +410,11 @@ dans le TP. #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/manipulation/02b_pandas_TP.qmd") +print_badges("content/manipulation/02b_pandas_TP.qmd") ``` ::: @@ -622,11 +622,11 @@ Les exercices de TD visent à démontrer l'intérêt de ces méthodes dans quelq #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/manipulation/02b_pandas_TP.qmd") +print_badges("content/manipulation/02b_pandas_TP.qmd") ``` ::: @@ -1143,11 +1143,11 @@ Le chapitre suivant, qui fait office de TP, proposera des applications de ces pr #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/manipulation/02b_pandas_TP.qmd") +print_badges("content/manipulation/02b_pandas_TP.qmd") ``` ::: diff --git a/content/course/manipulation/02b_pandas_TP/index.qmd b/content/manipulation/02b_pandas_TP.qmd similarity index 99% rename from content/course/manipulation/02b_pandas_TP/index.qmd rename to content/manipulation/02b_pandas_TP.qmd index 9b818d3d8..11a1acf79 100644 --- a/content/course/manipulation/02b_pandas_TP/index.qmd +++ b/content/manipulation/02b_pandas_TP.qmd @@ -34,11 +34,11 @@ Les exemples de ce TP sont visualisables sous forme de `Jupyter Notebooks`: #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/manipulation/02b_pandas_TP.qmd") +print_badges("content/manipulation/02b_pandas_TP.qmd") ``` ::: diff --git a/content/course/manipulation/03_geopandas_TP/index.qmd b/content/manipulation/03_geopandas_TP.qmd similarity index 99% rename from content/course/manipulation/03_geopandas_TP/index.qmd rename to content/manipulation/03_geopandas_TP.qmd index 01fcdcd4f..5cd3f3a9d 100644 --- a/content/course/manipulation/03_geopandas_TP/index.qmd +++ b/content/manipulation/03_geopandas_TP.qmd @@ -33,11 +33,11 @@ image: featured.png #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/manipulation/03_geopandas_TP.qmd") +print_badges("content/manipulation/03_geopandas_TP.qmd") ``` ::: diff --git a/content/course/manipulation/03_geopandas_tutorial/index.qmd b/content/manipulation/03_geopandas_tutorial.qmd similarity index 99% rename from content/course/manipulation/03_geopandas_tutorial/index.qmd rename to content/manipulation/03_geopandas_tutorial.qmd index 712f869c1..5f9eeab1e 100644 --- a/content/course/manipulation/03_geopandas_tutorial/index.qmd +++ b/content/manipulation/03_geopandas_tutorial.qmd @@ -31,11 +31,11 @@ image: featured.png #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/manipulation/03_geopandas_tutorial.qmd") +print_badges("content/manipulation/03_geopandas_tutorial.qmd") ``` ::: diff --git a/content/course/manipulation/04a_webscraping_TP/index.qmd b/content/manipulation/04a_webscraping_TP.qmd similarity index 99% rename from content/course/manipulation/04a_webscraping_TP/index.qmd rename to content/manipulation/04a_webscraping_TP.qmd index a295f4181..dd3f4e8e8 100644 --- a/content/course/manipulation/04a_webscraping_TP/index.qmd +++ b/content/manipulation/04a_webscraping_TP.qmd @@ -30,11 +30,11 @@ image: featured.jpg #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/manipulation/04a_webscraping_TP.qmd") +print_badges("content/manipulation/04a_webscraping_TP.qmd") ``` ::: diff --git a/content/course/manipulation/04b_regex_TP/index.qmd b/content/manipulation/04b_regex_TP.qmd similarity index 99% rename from content/course/manipulation/04b_regex_TP/index.qmd rename to content/manipulation/04b_regex_TP.qmd index 3983a0cb7..0ba303a6d 100644 --- a/content/course/manipulation/04b_regex_TP/index.qmd +++ b/content/manipulation/04b_regex_TP.qmd @@ -30,11 +30,11 @@ image: https://d2h1bfu6zrdxog.cloudfront.net/wp-content/uploads/2022/04/img_6254 #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/manipulation/04b_regex_TP.qmd") +print_badges("content/manipulation/04b_regex_TP.qmd") ``` ::: diff --git a/content/course/manipulation/04c_API_TP/index.qmd b/content/manipulation/04c_API_TP.qmd similarity index 99% rename from content/course/manipulation/04c_API_TP/index.qmd rename to content/manipulation/04c_API_TP.qmd index fd3d243af..b64cd25ce 100644 --- a/content/course/manipulation/04c_API_TP/index.qmd +++ b/content/manipulation/04c_API_TP.qmd @@ -32,11 +32,11 @@ image: map_buffer.png #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/manipulation/04c_API_TP.qmd") +print_badges("content/manipulation/04c_API_TP.qmd") ``` ::: diff --git a/content/course/manipulation/06a_exo_supp_webscraping/index.qmd b/content/manipulation/06a_exo_supp_webscraping.qmd similarity index 98% rename from content/course/manipulation/06a_exo_supp_webscraping/index.qmd rename to content/manipulation/06a_exo_supp_webscraping.qmd index 2c6a677f6..51b0211c8 100644 --- a/content/course/manipulation/06a_exo_supp_webscraping/index.qmd +++ b/content/manipulation/06a_exo_supp_webscraping.qmd @@ -30,11 +30,11 @@ image: featured.png #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/manipulation/06a_exo_supp_webscraping.qmd") +print_badges("content/manipulation/06a_exo_supp_webscraping.qmd") ``` ::: diff --git a/content/course/manipulation/07_dask/index.qmd b/content/manipulation/07_dask.qmd similarity index 99% rename from content/course/manipulation/07_dask/index.qmd rename to content/manipulation/07_dask.qmd index ff78845ae..9942d1920 100644 --- a/content/course/manipulation/07_dask/index.qmd +++ b/content/manipulation/07_dask.qmd @@ -34,11 +34,11 @@ Pour essayer les exemples présents dans ce tutoriel : #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/manipulation/07_dask.qmd") +print_badges("content/manipulation/07_dask.qmd") ``` ::: diff --git a/content/course/manipulation/index.qmd b/content/manipulation/index.qmd similarity index 99% rename from content/course/manipulation/index.qmd rename to content/manipulation/index.qmd index e017405b4..095beb003 100644 --- a/content/course/manipulation/index.qmd +++ b/content/manipulation/index.qmd @@ -149,7 +149,7 @@ sys.path.insert(1, '../../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/manipulation/02b_pandas_TP.qmd") +print_badges("content/manipulation/02b_pandas_TP.qmd") ``` ::: diff --git a/content/course/modelisation/0_preprocessing/index.qmd b/content/modelisation/0_preprocessing.qmd similarity index 99% rename from content/course/modelisation/0_preprocessing/index.qmd rename to content/modelisation/0_preprocessing.qmd index abe2083bd..e281d8413 100644 --- a/content/course/modelisation/0_preprocessing/index.qmd +++ b/content/modelisation/0_preprocessing.qmd @@ -36,11 +36,11 @@ image: featured #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/modelisation/0_preprocessing.qmd") +print_badges("content/modelisation/0_preprocessing.qmd") ``` ::: @@ -49,7 +49,7 @@ de cette partie](https://linogaliana-teaching.netlify.app/modelisation/) : les données de vote aux élections présidentielles américaines de 2020 au niveau des comtés croisées à des variables socio-démographiques. Le code de consitution de la base de données -est disponible [sur Github](https://github.com/linogaliana/python-datascientist/blob/master/content/course/modelisation/get_data.py). +est disponible [sur Github](https://github.com/linogaliana/python-datascientist/blob/master/content/modelisation/get_data.py). L'exercice 1 permet, à ceux qui le désirent, d'essayer de le reconstituer pas à pas. Le guide utilisateur de `scikit` est une référence précieuse, @@ -149,7 +149,7 @@ Si vous ne faites pas l'exercice 1, pensez à charger les données en executant import requests -url = 'https://raw.githubusercontent.com/linogaliana/python-datascientist/master/content/course/modelisation/get_data.py' +url = 'https://raw.githubusercontent.com/linogaliana/python-datascientist/master/content/modelisation/get_data.py' r = requests.get(url, allow_redirects=True) open('getdata.py', 'wb').write(r.content) diff --git a/content/course/modelisation/1_modelevaluation/index.qmd b/content/modelisation/1_modelevaluation.qmd similarity index 99% rename from content/course/modelisation/1_modelevaluation/index.qmd rename to content/modelisation/1_modelevaluation.qmd index cc44a8cdb..5d8c6b899 100644 --- a/content/course/modelisation/1_modelevaluation/index.qmd +++ b/content/modelisation/1_modelevaluation.qmd @@ -38,11 +38,11 @@ image: featured #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/modelisation/1_modelevaluation.qmd") +print_badges("content/modelisation/1_modelevaluation.qmd") ``` ::: diff --git a/content/course/modelisation/2_SVM/index.qmd b/content/modelisation/2_SVM.qmd similarity index 97% rename from content/course/modelisation/2_SVM/index.qmd rename to content/modelisation/2_SVM.qmd index 5fc159b3c..613964afc 100644 --- a/content/course/modelisation/2_SVM/index.qmd +++ b/content/modelisation/2_SVM.qmd @@ -36,11 +36,11 @@ image: featured.png #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/modelisation/2_SVM.qmd") +print_badges("content/modelisation/2_SVM.qmd") ``` ::: @@ -49,7 +49,7 @@ c'est-à-dire les résultats des élections US 2020 présentés dans l'[introduc de cette partie](https://linogaliana-teaching.netlify.app/modelisation/): les données de vote aux élections présidentielles américaines croisées à des variables sociodémographiques. Le code -est disponible [sur Github](https://github.com/linogaliana/python-datascientist/blob/master/content/course/modelisation/get_data.py). +est disponible [sur Github](https://github.com/linogaliana/python-datascientist/blob/master/content/modelisation/get_data.py). ```{python} @@ -62,7 +62,7 @@ est disponible [sur Github](https://github.com/linogaliana/python-datascientist/ import requests -url = 'https://raw.githubusercontent.com/linogaliana/python-datascientist/master/content/course/modelisation/get_data.py' +url = 'https://raw.githubusercontent.com/linogaliana/python-datascientist/master/content/modelisation/get_data.py' r = requests.get(url, allow_redirects=True) open('getdata.py', 'wb').write(r.content) diff --git a/content/course/modelisation/3_regression/index.qmd b/content/modelisation/3_regression.qmd similarity index 98% rename from content/course/modelisation/3_regression/index.qmd rename to content/modelisation/3_regression.qmd index e97ccb361..980a69b0c 100644 --- a/content/course/modelisation/3_regression/index.qmd +++ b/content/modelisation/3_regression.qmd @@ -34,11 +34,11 @@ image: featured.png #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/modelisation/3_regression.qmd") +print_badges("content/modelisation/3_regression.qmd") ``` ::: @@ -48,7 +48,7 @@ c'est-à-dire les résultats des élections US 2020 présentés dans l'[introduc de cette partie](https://linogaliana-teaching.netlify.app/modelisation/): les données de vote aux élections présidentielles américaines croisées à des variables sociodémographiques. Le code -est disponible [sur Github](https://github.com/linogaliana/python-datascientist/blob/master/content/course/modelisation/get_data.py). +est disponible [sur Github](https://github.com/linogaliana/python-datascientist/blob/master/content/modelisation/get_data.py). ```{python} @@ -61,7 +61,7 @@ est disponible [sur Github](https://github.com/linogaliana/python-datascientist/ import requests -url = 'https://raw.githubusercontent.com/linogaliana/python-datascientist/master/content/course/modelisation/get_data.py' +url = 'https://raw.githubusercontent.com/linogaliana/python-datascientist/master/content/modelisation/get_data.py' r = requests.get(url, allow_redirects=True) open('getdata.py', 'wb').write(r.content) @@ -85,7 +85,7 @@ Ce chapitre utilise toujours le même jeu de données, présenté dans l'[introd de cette partie](https://linogaliana-teaching.netlify.app/modelisation/): les données de vote aux élections présidentielles américaines croisées à des variables sociodémographiques. Le code -est disponible [sur Github](https://github.com/linogaliana/python-datascientist/blob/master/content/course/modelisation/get_data.py). +est disponible [sur Github](https://github.com/linogaliana/python-datascientist/blob/master/content/modelisation/get_data.py). ```{python} #| include: false @@ -96,7 +96,7 @@ est disponible [sur Github](https://github.com/linogaliana/python-datascientist/ import requests -url = 'https://raw.githubusercontent.com/linogaliana/python-datascientist/master/content/course/modelisation/get_data.py' +url = 'https://raw.githubusercontent.com/linogaliana/python-datascientist/master/content/modelisation/get_data.py' r = requests.get(url, allow_redirects=True) open('getdata.py', 'wb').write(r.content) diff --git a/content/course/modelisation/4_featureselection/index.qmd b/content/modelisation/4_featureselection.qmd similarity index 98% rename from content/course/modelisation/4_featureselection/index.qmd rename to content/modelisation/4_featureselection.qmd index c9f0d5802..873b8224b 100644 --- a/content/course/modelisation/4_featureselection/index.qmd +++ b/content/modelisation/4_featureselection.qmd @@ -41,11 +41,11 @@ image: featured.png #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/modelisation/4_featureselection.qmd") +print_badges("content/modelisation/4_featureselection.qmd") ``` ::: @@ -57,7 +57,7 @@ c'est-à-dire les résultats des élections US 2020 présentés dans l'[introduc de cette partie](https://linogaliana-teaching.netlify.app/modelisation/): les données de vote aux élections présidentielles américaines croisées à des variables sociodémographiques. Le code -est disponible [sur Github](https://github.com/linogaliana/python-datascientist/blob/master/content/course/modelisation/get_data.py). +est disponible [sur Github](https://github.com/linogaliana/python-datascientist/blob/master/content/modelisation/get_data.py). ```{python} @@ -70,7 +70,7 @@ est disponible [sur Github](https://github.com/linogaliana/python-datascientist/ import requests -url = 'https://raw.githubusercontent.com/linogaliana/python-datascientist/master/content/course/modelisation/get_data.py' +url = 'https://raw.githubusercontent.com/linogaliana/python-datascientist/master/content/modelisation/get_data.py' r = requests.get(url, allow_redirects=True) open('getdata.py', 'wb').write(r.content) diff --git a/content/course/modelisation/5_clustering/index.qmd b/content/modelisation/5_clustering.qmd similarity index 98% rename from content/course/modelisation/5_clustering/index.qmd rename to content/modelisation/5_clustering.qmd index 17c71a28d..25556e8d8 100644 --- a/content/course/modelisation/5_clustering/index.qmd +++ b/content/modelisation/5_clustering.qmd @@ -37,11 +37,11 @@ image: featured.png #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/modelisation/5_clustering.qmd") +print_badges("content/modelisation/5_clustering.qmd") ``` ::: @@ -52,7 +52,7 @@ c'est-à-dire les résultats des élections US 2020 présentés dans l'[introduc de cette partie](https://linogaliana-teaching.netlify.app/modelisation/): les données de vote aux élections présidentielles américaines croisées à des variables sociodémographiques. Le code -est disponible [sur Github](https://github.com/linogaliana/python-datascientist/blob/master/content/course/modelisation/get_data.py). +est disponible [sur Github](https://github.com/linogaliana/python-datascientist/blob/master/content/modelisation/get_data.py). ```{python} @@ -65,7 +65,7 @@ est disponible [sur Github](https://github.com/linogaliana/python-datascientist/ import requests -url = 'https://raw.githubusercontent.com/linogaliana/python-datascientist/master/content/course/modelisation/get_data.py' +url = 'https://raw.githubusercontent.com/linogaliana/python-datascientist/master/content/modelisation/get_data.py' r = requests.get(url, allow_redirects=True) open('getdata.py', 'wb').write(r.content) diff --git a/content/course/modelisation/6_pipeline/index.qmd b/content/modelisation/6_pipeline.qmd similarity index 99% rename from content/course/modelisation/6_pipeline/index.qmd rename to content/modelisation/6_pipeline.qmd index bd4c5b72f..7f3a64c65 100644 --- a/content/course/modelisation/6_pipeline/index.qmd +++ b/content/modelisation/6_pipeline.qmd @@ -33,11 +33,11 @@ image: featured.png #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/modelisation/6_pipeline.qmd") +print_badges("content/modelisation/6_pipeline.qmd") ``` ::: diff --git a/content/course/modelisation/get_data.py b/content/modelisation/get_data.py similarity index 100% rename from content/course/modelisation/get_data.py rename to content/modelisation/get_data.py diff --git a/content/course/modelisation/index.qmd b/content/modelisation/index.qmd similarity index 100% rename from content/course/modelisation/index.qmd rename to content/modelisation/index.qmd diff --git a/content/course/modern-ds/continuous_integration/index.qmd b/content/modern-ds/continuous_integration.qmd similarity index 100% rename from content/course/modern-ds/continuous_integration/index.qmd rename to content/modern-ds/continuous_integration.qmd diff --git a/content/course/modern-ds/dallE/index.qmd b/content/modern-ds/dallE.qmd similarity index 99% rename from content/course/modern-ds/dallE/index.qmd rename to content/modern-ds/dallE.qmd index 967d45a9b..1e26e47db 100644 --- a/content/course/modern-ds/dallE/index.qmd +++ b/content/modern-ds/dallE.qmd @@ -27,6 +27,7 @@ description: | soit-même ses propres images rigolotes. bibliography: ../../../../reference.bib +image: featured_dallE.png --- Pour tester les exemples présentés dans ce chapitre: @@ -39,11 +40,11 @@ Pour tester les exemples présentés dans ce chapitre: #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/modern-ds/dallE.qmd", GPU = True) +print_badges("content/modern-ds/dallE.qmd", GPU = True) ``` ::: diff --git a/content/course/modern-ds/elastic_approfondissement/index.qmd b/content/modern-ds/elastic_approfondissement.qmd similarity index 99% rename from content/course/modern-ds/elastic_approfondissement/index.qmd rename to content/modern-ds/elastic_approfondissement.qmd index cf70fde31..5999ea15d 100644 --- a/content/course/modern-ds/elastic_approfondissement/index.qmd +++ b/content/modern-ds/elastic_approfondissement.qmd @@ -27,11 +27,11 @@ Pour essayer les exemples présents dans ce tutoriel : #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/modern-ds/elastic_approfondissement.qmd") +print_badges("content/modern-ds/elastic_approfondissement.qmd") ``` ::: diff --git a/content/course/modern-ds/elastic_intro/index.qmd b/content/modern-ds/elastic_intro.qmd similarity index 99% rename from content/course/modern-ds/elastic_intro/index.qmd rename to content/modern-ds/elastic_intro.qmd index 9a70b1b9a..89cb55556 100644 --- a/content/course/modern-ds/elastic_intro/index.qmd +++ b/content/modern-ds/elastic_intro.qmd @@ -34,11 +34,11 @@ Pour essayer les exemples présents dans ce tutoriel : #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/modern-ds/elastic_intro.qmd") +print_badges("content/modern-ds/elastic_intro.qmd") ``` ::: @@ -101,7 +101,7 @@ version sur le dépôt `Github` du cours import requests baseurl = "https://raw.githubusercontent.com/linogaliana/python-datascientist" branch = "master" -path = "content/course/modern-ds/elastic_intro/functions.py" +path = "content/modern-ds/elastic_intro/functions.py" url = f"{baseurl}/{branch}/{path}" r = requests.get(url, allow_redirects=True) diff --git a/content/course/modern-ds/elastic_approfondissement/functions.py b/content/modern-ds/functions-approfondissement.py similarity index 100% rename from content/course/modern-ds/elastic_approfondissement/functions.py rename to content/modern-ds/functions-approfondissement.py diff --git a/content/course/modern-ds/elastic_intro/functions.py b/content/modern-ds/functions.py similarity index 100% rename from content/course/modern-ds/elastic_intro/functions.py rename to content/modern-ds/functions.py diff --git a/content/course/modern-ds/get_data.py b/content/modern-ds/get_data.py similarity index 100% rename from content/course/modern-ds/get_data.py rename to content/modern-ds/get_data.py diff --git a/content/course/modern-ds/index.qmd b/content/modern-ds/index.qmd similarity index 100% rename from content/course/modern-ds/index.qmd rename to content/modern-ds/index.qmd diff --git a/content/course/modern-ds/s3/index.qmd b/content/modern-ds/s3.qmd similarity index 99% rename from content/course/modern-ds/s3/index.qmd rename to content/modern-ds/s3.qmd index e2713ac16..f64493372 100644 --- a/content/course/modern-ds/s3/index.qmd +++ b/content/modern-ds/s3.qmd @@ -39,11 +39,11 @@ eval: false #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/NLP/05a_s3.qmd") +print_badges("content/NLP/05a_s3.qmd") ``` ::: @@ -683,7 +683,7 @@ SSP-cloud #| output: 'asis' #| include: true #| eval: true -print_badges("content/course/NLP/05a_s3.qmd", onyxia_only=True) +print_badges("content/NLP/05a_s3.qmd", onyxia_only=True) ``` Ils peuvent également l'être pour des utilisateurs ayant un diff --git a/content/course/visualisation/index.qmd b/content/visualisation/index.qmd similarity index 100% rename from content/course/visualisation/index.qmd rename to content/visualisation/index.qmd diff --git a/content/course/visualisation/maps/index.qmd b/content/visualisation/maps.qmd similarity index 99% rename from content/course/visualisation/maps/index.qmd rename to content/visualisation/maps.qmd index b874298e5..5989a2d19 100644 --- a/content/course/visualisation/maps/index.qmd +++ b/content/visualisation/maps.qmd @@ -36,11 +36,11 @@ image: featured.png #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/visualisation/maps.qmd") +print_badges("content/visualisation/maps.qmd") ``` ::: diff --git a/content/course/visualisation/matplotlib/index.qmd b/content/visualisation/matplotlib.qmd similarity index 99% rename from content/course/visualisation/matplotlib/index.qmd rename to content/visualisation/matplotlib.qmd index 5dda552e2..34368c29b 100644 --- a/content/course/visualisation/matplotlib/index.qmd +++ b/content/visualisation/matplotlib.qmd @@ -33,11 +33,11 @@ image: featured.png #| eval: true import sys -sys.path.insert(1, '../../../../') #insert the utils module +sys.path.insert(1, '../../') #insert the utils module from utils import print_badges #print_badges(__file__) -print_badges("content/course/visualisation/matplotlib.qmd") +print_badges("content/visualisation/matplotlib.qmd") ``` ::: diff --git a/content/course/visualisation/matplotlib/script_save_minio.py b/content/visualisation/script_save_minio.py similarity index 100% rename from content/course/visualisation/matplotlib/script_save_minio.py rename to content/visualisation/script_save_minio.py diff --git a/dev-scripts/change-structure.py b/dev-scripts/change-structure.py new file mode 100644 index 000000000..ebcdac9f0 --- /dev/null +++ b/dev-scripts/change-structure.py @@ -0,0 +1,13 @@ +import os +import glob +import shutil + +os.chdir("python-datascientist/content/") + +directory = "annexes" + +list_nested = glob.glob(f'{directory}/**/index.qmd', recursive=True) +list_nested = [f for f in list_nested if f != f'{directory}/index.qmd'] + +for f in list_nested: + shutil.move(f, f.replace("/index.qmd", ".qmd")) \ No newline at end of file diff --git a/dev-scripts/render-chapter.sh b/dev-scripts/render-chapter.sh index d37201a24..e53841bea 100644 --- a/dev-scripts/render-chapter.sh +++ b/dev-scripts/render-chapter.sh @@ -3,7 +3,7 @@ SECTION=$1 CHAPTER=$2 -SECTION_PATH="content/course/${SECTION}" +SECTION_PATH="content/${SECTION}" CHAPTER_PATH="${SECTION_PATH}/${CHAPTER}" quarto preview -port 5000 --host 0.0.0.0 diff --git a/index.qmd b/index.qmd index 57f2442ef..92b76810f 100644 --- a/index.qmd +++ b/index.qmd @@ -5,7 +5,7 @@ title-block-style: none css: homepage.css listing: id: sample-listings - contents: content/course/**/index.qmd + contents: content/**/*.qmd type: grid sort: "number" categories: true