fixed missing ai_user category

This commit is contained in:
2026-02-03 21:13:29 +01:00
parent 36280a6ff8
commit a35670aa72
4 changed files with 22 additions and 13 deletions

5
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,5 @@
{
"chat.tools.terminal.autoApprove": {
"/home/luigi/Documents/VoiceBranding/JPMC/Phase-3/.venv/bin/python": true
}
}

View File

@@ -7,7 +7,7 @@ import polars as pl
from pathlib import Path
import argparse
import json
import re
from validation import check_progress, duration_validation, check_straight_liners
from utils import QualtricsSurvey, combine_exclusive_columns, calculate_weighted_ranking_scores
import utils
@@ -149,7 +149,9 @@ if cli_args.filter_name and S.fig_save_dir:
_filter_desc_lines.append(f" {display_name}: All")
# Write detailed description INSIDE the filter-slug directory
_filter_file = _filter_slug_dir / f"{cli_args.filter_name}.txt"
# Sanitize filter name for filename usage (replace / and other chars)
_safe_filter_name = re.sub(r'[^\w\s-]', '_', cli_args.filter_name)
_filter_file = _filter_slug_dir / f"{_safe_filter_name}.txt"
_filter_file.write_text('\n'.join(_filter_desc_lines))
# Append to summary index file at figures/<export_date>/filter_index.txt

View File

@@ -157,9 +157,9 @@ def get_filter_combinations(survey: QualtricsSurvey, category: str = None) -> li
]}
})
combinations.append({
'name': 'AIUser-Infrequent',
'name': 'AIUser-RarelyNever',
'filters': {'ai_user': [
'Once a month', 'Less than once a month', 'Once a week'
'Once a month', 'Less than once a month', 'Once a week', 'Rarely/Never'
]}
})

View File

@@ -879,40 +879,42 @@ class QualtricsSurvey(QualtricsPlotsMixin):
"""
# Apply filters - skip if empty list (columns with all NULLs produce empty options)
# OR if all options are selected (to avoid dropping NULLs)
self.filter_age = age
if age is not None and len(age) > 0:
if age is not None and len(age) > 0 and set(age) != set(self.options_age):
q = q.filter(pl.col('QID1').is_in(age))
self.filter_gender = gender
if gender is not None and len(gender) > 0:
if gender is not None and len(gender) > 0 and set(gender) != set(self.options_gender):
q = q.filter(pl.col('QID2').is_in(gender))
self.filter_consumer = consumer
if consumer is not None and len(consumer) > 0:
if consumer is not None and len(consumer) > 0 and set(consumer) != set(self.options_consumer):
q = q.filter(pl.col('Consumer').is_in(consumer))
self.filter_ethnicity = ethnicity
if ethnicity is not None and len(ethnicity) > 0:
if ethnicity is not None and len(ethnicity) > 0 and set(ethnicity) != set(self.options_ethnicity):
q = q.filter(pl.col('QID3').is_in(ethnicity))
self.filter_income = income
if income is not None and len(income) > 0:
if income is not None and len(income) > 0 and set(income) != set(self.options_income):
q = q.filter(pl.col('QID15').is_in(income))
self.filter_business_owner = business_owner
if business_owner is not None and len(business_owner) > 0:
if business_owner is not None and len(business_owner) > 0 and set(business_owner) != set(self.options_business_owner):
q = q.filter(pl.col('QID4').is_in(business_owner))
self.filter_ai_user = ai_user
if ai_user is not None and len(ai_user) > 0:
if ai_user is not None and len(ai_user) > 0 and set(ai_user) != set(self.options_ai_user):
q = q.filter(pl.col('QID22').is_in(ai_user))
self.filter_investable_assets = investable_assets
if investable_assets is not None and len(investable_assets) > 0:
if investable_assets is not None and len(investable_assets) > 0 and set(investable_assets) != set(self.options_investable_assets):
q = q.filter(pl.col('QID16').is_in(investable_assets))
self.filter_industry = industry
if industry is not None and len(industry) > 0:
if industry is not None and len(industry) > 0 and set(industry) != set(self.options_industry):
q = q.filter(pl.col('QID17').is_in(industry))
self.data_filtered = q