File tree Expand file tree Collapse file tree
src/mindlogger_data_export Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -141,9 +141,14 @@ def _map_response_column_names(cname: str) -> str:
141141 return "_" .join ([parts [1 ], parts [0 ].removeprefix ("response" )])
142142
143143 @staticmethod
144- def _fill_item_response (* null_score_columns : str ) -> Generator [pl .Expr , None , None ]:
144+ def _fill_item_response (
145+ df : pl .DataFrame , * null_score_columns : str
146+ ) -> Generator [pl .Expr , None , None ]:
145147 for col in null_score_columns :
146- yield pl .col (f"{ col } __response" ).alias (col )
148+ if f"{ col } __response" in df .columns :
149+ yield pl .col (f"{ col } __response" ).alias (col )
150+ elif f"{ col } _response" in df .columns :
151+ yield pl .col (f"{ col } _response" ).alias (col )
147152
148153 @staticmethod
149154 def _pivot_singleselect (
@@ -225,7 +230,7 @@ def _pivot_singleselect(
225230 col for col in score_columns .values () if df [col ].is_null ().all ()
226231 }
227232 # Fill null <QUESTION> columns with value of <QUESTION>__response.
228- return df .with_columns (WideFormat ._fill_item_response (* null_score_columns ))
233+ return df .with_columns (WideFormat ._fill_item_response (df , * null_score_columns ))
229234
230235 @staticmethod
231236 def _pivot_text (
You can’t perform that action at this time.
0 commit comments