Skip to content

Commit

Permalink
Add item to questions_variables
Browse files Browse the repository at this point in the history
  • Loading branch information
hansendx committed Dec 7, 2022
1 parent 6afdfb0 commit b48b421
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions paneldata_pipeline/questions_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def create_questions_from_generations(version: str, input_folder: Path) -> DataF
logical_variables = read_csv(input_folder.joinpath("logical_variables.csv"))

logical_variables = logical_variables[
["study", "dataset", "variable", "instrument", "question"]
["study", "dataset", "variable", "instrument", "question", "item"]
]

# There are indirect links between variables and questions
Expand Down Expand Up @@ -123,6 +123,7 @@ def create_questions_from_generations(version: str, input_folder: Path) -> DataF
"output_variable",
"instrument",
"question",
"item",
]
indirect_relations = indirect_relations[wanted_columns]

Expand All @@ -132,6 +133,7 @@ def create_questions_from_generations(version: str, input_folder: Path) -> DataF
"output_variable": "variable",
"questionnaire": "instrument",
"question": "question",
"item": "item",
}

indirect_relations.rename(columns=column_filter, inplace=True)
Expand All @@ -140,7 +142,7 @@ def create_questions_from_generations(version: str, input_folder: Path) -> DataF
questions_variables.dropna(inplace=True)
questions_variables.drop_duplicates(inplace=True)

sort_columns = ["study", "dataset", "variable", "instrument", "question"]
sort_columns = ["study", "dataset", "variable", "instrument", "question", "item"]

questions_variables.sort_values(by=sort_columns, inplace=True)

Expand Down
6 changes: 3 additions & 3 deletions tests/test_data/expected/questions_variables.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
study,dataset,variable,instrument,question
some-study,some-dataset,some-other-variable,some-instrument,1
some-study,some-dataset,some-variable,some-instrument,1
study,dataset,variable,instrument,question,item
some-study,some-dataset,some-other-variable,some-instrument,1,some-item
some-study,some-dataset,some-variable,some-instrument,1,some-item

0 comments on commit b48b421

Please sign in to comment.