Before running your cross-tab analysis you need to flag incomplete responses — rows where a required field is missing or empty. How do you handle that in Excel right now?
ISBLANK in a helper column, then filter. It works but I have to redo it every time I get a new export.
format_summary_line from yesterday gave you numeric formatting for clean rows. Now we handle the dirty ones. Python's in operator checks membership — "major" in response is True if the key exists in the response dict, False otherwise. Combine checks with and to require all fields:
response = {"major": "Economics", "year": "Junior"}
required = ["major", "year", "satisfaction"]
all_present = all(field in response and response[field] for field in required)
print(all_present) # False — satisfaction missingall(...) — is that a loop inside a function? I thought we hadn't done loops yet.
all() is a built-in that checks a sequence of booleans — it returns True only if every item is truthy. You can also write it with and explicitly: "major" in r and r["major"] checks both presence and non-empty value. The pattern that matters is the bool return — True or False, nothing else:
def is_valid_response(response: dict, required_fields: list) -> bool:
for field in required_fields:
if field not in response or not response[field]:
return False
return TrueSo I can call this before format_summary_line and skip any rows that would break the calculation?
Exactly. Your whole cleaning pipeline is two function calls: validate first, format what passes.
ISBLANK in a helper column felt like a workaround. This is an actual data cleaning step.
not response[field] catches both missing keys and empty strings in one check. An empty string "" is falsy in Python — same as False in a boolean context. A space " " is truthy, so strip your strings before validating — or your cleaning step from Day 4 handles that for you.
Python's bool type has two values: True and False. Comparison operators return bools:
| Operator | Meaning |
|---|---|
== / != | Equal / not equal |
in | Membership check in list or dict |
and / or / not | Combine or negate |
Empty string "", 0, None, and [] are all falsy — they evaluate to False in a boolean context. Non-empty strings and non-zero numbers are truthy.
field not in response or not response[field] flags both absent keys and empty values in one condition.
Before running your cross-tab analysis you need to flag incomplete responses — rows where a required field is missing or empty. How do you handle that in Excel right now?
ISBLANK in a helper column, then filter. It works but I have to redo it every time I get a new export.
format_summary_line from yesterday gave you numeric formatting for clean rows. Now we handle the dirty ones. Python's in operator checks membership — "major" in response is True if the key exists in the response dict, False otherwise. Combine checks with and to require all fields:
response = {"major": "Economics", "year": "Junior"}
required = ["major", "year", "satisfaction"]
all_present = all(field in response and response[field] for field in required)
print(all_present) # False — satisfaction missingall(...) — is that a loop inside a function? I thought we hadn't done loops yet.
all() is a built-in that checks a sequence of booleans — it returns True only if every item is truthy. You can also write it with and explicitly: "major" in r and r["major"] checks both presence and non-empty value. The pattern that matters is the bool return — True or False, nothing else:
def is_valid_response(response: dict, required_fields: list) -> bool:
for field in required_fields:
if field not in response or not response[field]:
return False
return TrueSo I can call this before format_summary_line and skip any rows that would break the calculation?
Exactly. Your whole cleaning pipeline is two function calls: validate first, format what passes.
ISBLANK in a helper column felt like a workaround. This is an actual data cleaning step.
not response[field] catches both missing keys and empty strings in one check. An empty string "" is falsy in Python — same as False in a boolean context. A space " " is truthy, so strip your strings before validating — or your cleaning step from Day 4 handles that for you.
Python's bool type has two values: True and False. Comparison operators return bools:
| Operator | Meaning |
|---|---|
== / != | Equal / not equal |
in | Membership check in list or dict |
and / or / not | Combine or negate |
Empty string "", 0, None, and [] are all falsy — they evaluate to False in a boolean context. Non-empty strings and non-zero numbers are truthy.
field not in response or not response[field] flags both absent keys and empty values in one condition.
You need to filter his Qualtrics export before analysis — rows with missing or empty required fields will break his cross-tab calculations. Write `is_valid_response(response, required_fields)` that returns `True` if all fields in `required_fields` are present and non-empty in the response dict, `False` otherwise.
Tap each step for scaffolded hints.
No blank-editor panic.