File tree Expand file tree Collapse file tree 1 file changed +17
-20
lines changed
src/mindlogger_data_export Expand file tree Collapse file tree 1 file changed +17
-20
lines changed Original file line number Diff line number Diff line change @@ -514,27 +514,24 @@ def _prepare_activity_columns(
514514 # No original response column, use index + 1
515515 df = df .with_columns ([(pl .col (col ) + 1 ).alias (response_col )])
516516
517- # Drop bare item columns that have _response, _score, or _index versions
518- response_bases = {
519- col .replace ("_response" , "" )
520- for col in df .columns
521- if col .endswith ("_response" )
522- }
523- score_bases = {
524- col .replace ("_score" , "" ) for col in df .columns if col .endswith ("_score" )
525- }
526- index_bases = {
527- col .replace ("_index" , "" ) for col in df .columns if col .endswith ("_index" )
528- }
529-
530- return df .select (
531- [
532- col
517+ return df .rename (
518+ {
519+ col : col .replace (
520+ f"{ activity_prefix } _response_response_" , f"{ activity_prefix } _"
521+ ).replace ("_response_response_" , "_" )
522+ + "_response"
533523 for col in df .columns
534- if col not in (response_bases | score_bases | index_bases )
535- and not col .startswith (f"{ activity_prefix } _response_response_" )
536- and not col .startswith (f"{ activity_prefix } _response_value_" )
537- ]
524+ if f"{ activity_prefix } _response_response_" in col
525+ }
526+ ).rename (
527+ {
528+ col : col .replace (
529+ f"{ activity_prefix } _response_value_" , f"{ activity_prefix } _"
530+ ).replace ("_response_value_" , "_" )
531+ + "_score"
532+ for col in df .columns
533+ if f"{ activity_prefix } _response_value_" in col
534+ }
538535 )
539536
540537 def _format_activity (self , df : pl .DataFrame , activity_name : str ) -> pl .DataFrame :
You can’t perform that action at this time.
0 commit comments