Skip to content

Commit

Permalink
Merge pull request #71 from sensein/69-load_and_pivot_questionnaire-c…
Browse files Browse the repository at this point in the history
…annot-reindex-on-an-axis-with-duplicate-labels

Fix duplicate pd df indexes bug
  • Loading branch information
alistairewj authored Jun 27, 2024
2 parents dd025ca + e49684e commit 626b06c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/b2aiprep/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,14 @@ def load_and_pivot_questionnaire(self, questionnaire_name: str) -> pd.DataFrame:
# concatenate all the dataframes
pivoted_df = pd.concat(q_dfs)


# create a value column that merges valueString, valueBoolean, etc.
# https://hl7.org/fhir/r4/questionnaireresponse-definitions.html#QuestionnaireResponse.item.answer.value_x_
# boolean|decimal|integer|date|dateTime|time|string|uri|Attachment|Coding|Quantity|Reference(Any)
# currently we only support String/Boolean
value_columns = ['valueString', 'valueBoolean']
pivoted_df['value'] = None
pivoted_df = pivoted_df.reset_index(drop=True)
for col in value_columns:
if col in pivoted_df.columns:
pivoted_df['value'] = pivoted_df['value'].combine_first(pivoted_df[col])
Expand Down

0 comments on commit 626b06c

Please sign in to comment.