From 284a3b9281c25165389086895d8db66f6858ae2b Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 15 Jul 2024 21:12:39 +0200 Subject: [PATCH] chore(code): Move dataframe generation to module --- article.qmd | 19 ++++++++++++++++--- scoping_review.qmd | 18 ++++++++++++++++-- .../process/generate_dataframes.py | 10 ---------- 3 files changed, 32 insertions(+), 15 deletions(-) rename 01-codechunks/_prep-data.py => src/process/generate_dataframes.py (90%) diff --git a/article.qmd b/article.qmd index 912ce14..79b4ca4 100644 --- a/article.qmd +++ b/article.qmd @@ -38,12 +38,25 @@ crossref: # to fix the appendix crossrefs being separate from main latex-list-of-description: Appendix B Table --- - ```{python} -#| label: prep-data +#| label: standard-imports #| echo: false #| output: false -{{< include 01-codechunks/_prep-data.py >}} +import src.globals as g +from IPython.display import display, Markdown, HTML +import numpy as np +import pandas as pd +from matplotlib import pyplot as plt +from tabulate import tabulate +import seaborn as sns +sns.set_style("whitegrid") +``` + +```{python} +#| label: load-dataframes +#| echo: false +#| output: false +from src.process.generate_dataframes import df, df_by_intervention, validities ``` {{< portrait >}} diff --git a/scoping_review.qmd b/scoping_review.qmd index cd0ebd0..63c206a 100644 --- a/scoping_review.qmd +++ b/scoping_review.qmd @@ -22,10 +22,24 @@ crossref: --- ```{python} -#| label: prep-data +#| label: standard-imports #| echo: false #| output: false -{{< include 01-codechunks/_prep-data.py >}} +import src.globals as g +from IPython.display import display, Markdown, HTML +import numpy as np +import pandas as pd +from matplotlib import pyplot as plt +from tabulate import tabulate +import seaborn as sns +sns.set_style("whitegrid") +``` + +```{python} +#| label: load-dataframes +#| echo: false +#| output: false +from src.process.generate_dataframes import df, df_by_intervention, validities ``` diff --git a/01-codechunks/_prep-data.py b/src/process/generate_dataframes.py similarity index 90% rename from 01-codechunks/_prep-data.py rename to src/process/generate_dataframes.py index 8287e65..a5bab48 100644 --- a/01-codechunks/_prep-data.py +++ b/src/process/generate_dataframes.py @@ -1,18 +1,8 @@ from pathlib import Path -import os import re -## standard imports -from IPython.display import display, Markdown, HTML -import numpy as np -import pandas as pd -from matplotlib import pyplot as plt import seaborn as sns -from tabulate import tabulate -import bibtexparser import src.globals as g -sns.set_style("whitegrid") - ## Creates 3 important data structures: # df: The main dataframe containing all final sample studies # df_by_intervention: The same dataframe but split up by individual interventions per study