refactor(code): Rename validity module
From strength of findings to the more general validity module, which can then in turn contain the 'add_to_findings' function which unsurprisingly adds validities to findings. Makes more sense to me.
This commit is contained in:
parent
5f9f3a1370
commit
8333bbe9be
2 changed files with 8 additions and 8 deletions
|
@ -634,10 +634,10 @@ g = sns.PairGrid(validities[["internal_validity", "external_validity", "identifi
|
||||||
|
|
||||||
```{python}
|
```{python}
|
||||||
#| label: tbl-findings-institutional
|
#| label: tbl-findings-institutional
|
||||||
from src.model import strength_of_findings as findings
|
from src.model import validity
|
||||||
|
|
||||||
findings_institutional = pd.read_csv("02-data/supplementary/findings-institutional.csv")
|
findings_institutional = pd.read_csv("02-data/supplementary/findings-institutional.csv")
|
||||||
fd_df = findings.add_validities(findings_institutional, by_intervention)
|
fd_df = validity.add_to_findings(findings_institutional, by_intervention)
|
||||||
|
|
||||||
md(tabulate(fd_df[["area of policy", "internal_validity", "external_validity", "findings", "channels"]].fillna(""), showindex=False, headers="keys", tablefmt="grid"))
|
md(tabulate(fd_df[["area of policy", "internal_validity", "external_validity", "findings", "channels"]].fillna(""), showindex=False, headers="keys", tablefmt="grid"))
|
||||||
```
|
```
|
||||||
|
@ -865,10 +865,10 @@ One limitation of the study is the modelling assumption that workers will have t
|
||||||
|
|
||||||
```{python}
|
```{python}
|
||||||
#| label: tbl-findings-structural
|
#| label: tbl-findings-structural
|
||||||
from src.model import strength_of_findings as findings
|
from src.model import validity
|
||||||
|
|
||||||
findings_structural = pd.read_csv("02-data/supplementary/findings-structural.csv")
|
findings_structural = pd.read_csv("02-data/supplementary/findings-structural.csv")
|
||||||
fd_df = findings.add_validities(findings_structural, by_intervention)
|
fd_df = validity.add_to_findings(findings_structural, by_intervention)
|
||||||
|
|
||||||
md(tabulate(fd_df[["area of policy", "internal_validity", "external_validity", "findings", "channels"]].fillna(""), showindex=False, headers="keys", tablefmt="grid"))
|
md(tabulate(fd_df[["area of policy", "internal_validity", "external_validity", "findings", "channels"]].fillna(""), showindex=False, headers="keys", tablefmt="grid"))
|
||||||
```
|
```
|
||||||
|
@ -1100,10 +1100,10 @@ Though the intervention clearly aims at strengthening some aspect of individual
|
||||||
|
|
||||||
```{python}
|
```{python}
|
||||||
#| label: tbl-findings-agency
|
#| label: tbl-findings-agency
|
||||||
from src.model import strength_of_findings as findings
|
from src.model import validity
|
||||||
|
|
||||||
findings_agency = pd.read_csv("02-data/supplementary/findings-agency.csv")
|
findings_agency = pd.read_csv("02-data/supplementary/findings-agency.csv")
|
||||||
fd_df = findings.add_validities(findings_agency, by_intervention)
|
fd_df = validity.add_to_findings(findings_agency, by_intervention)
|
||||||
|
|
||||||
md(tabulate(fd_df[["area of policy", "internal_validity", "external_validity", "findings", "channels"]].fillna(""), showindex=False, headers="keys", tablefmt="grid"))
|
md(tabulate(fd_df[["area of policy", "internal_validity", "external_validity", "findings", "channels"]].fillna(""), showindex=False, headers="keys", tablefmt="grid"))
|
||||||
```
|
```
|
||||||
|
|
|
@ -28,7 +28,7 @@ def _combined_validities(
|
||||||
return r"\-"
|
return r"\-"
|
||||||
|
|
||||||
|
|
||||||
def add_validities(
|
def add_to_findings(
|
||||||
findings_df: DataFrame, studies_by_intervention: DataFrame
|
findings_df: DataFrame, studies_by_intervention: DataFrame
|
||||||
) -> DataFrame:
|
) -> DataFrame:
|
||||||
valid_subset = (
|
valid_subset = (
|
||||||
|
@ -36,7 +36,7 @@ def add_validities(
|
||||||
["internal_validity", "external_validity", "citation"]
|
["internal_validity", "external_validity", "citation"]
|
||||||
]
|
]
|
||||||
.fillna(1.0)
|
.fillna(1.0)
|
||||||
.drop_duplicates(subset=["citation"])
|
.drop_duplicates(subset=["citation"]) # type: ignore
|
||||||
.sort_values("internal_validity")
|
.sort_values("internal_validity")
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue