soundscapy developer on retainer: PAQ column names are case-sensitive — ‘Pleasant’ not found, allow_missing=True silently returns NaN — circumplex plot blank after 3-month survey — soundscapy developer on monthly retainer
soundscapy 0.7.1 • Python 3.10; survey export uses 'Pleasant', 'Vibrant', etc. (title case); load_paqs() expects lowercase 'pleasant', 'vibrant'; allow_missing=True silently substitutes NaN for all 8 PAQ attributes; ISOPleasant=NaN, ISOEventful=NaN; circumplex_plot() renders empty canvas with no data points; 50-location city survey; 3 months; fix: df.columns = df.columns.str.lower() • Northfield Soundscapy Ltd. (urban soundscape quality monitoring; 50 city parks and transit corridors; 20 participants per location; 3 months; 2.0h retainer engagement)
Northfield Soundscapy Ltd. conducted a 3-month urban soundscape quality survey across 50 locations in a mid-sized European city — parks, transit hubs, residential streets, and commercial plazas — in support of a city planning department’s acoustic environment assessment. Twenty participants rated each location using the ISO 12913 Perceived Affective Quality (PAQ) instrument: eight semantic differential attributes (pleasant, vibrant, eventful, chaotic, annoying, monotonous, uneventful, calm) each scored 1–5 (1 = strongly disagree, 5 = strongly agree). The survey ran on a custom mobile app that exported response data to Excel. The developer loaded these exports into soundscapy (0.7.1) using sspy.DataLoader.load_paqs(df, allow_missing=True) and called sspy.circumplex_plot(data) to generate the ISO 12913-2 circumplex showing all 50 locations in the ISOPleasant–ISOEventful two-dimensional space. The circumplex rendered perfectly — axis grid, quadrant zone boundaries, attribute labels around the perimeter — but contained zero data points. Every location was absent from the plot. soundscapy raised no exception. The pipeline ran to completion without error. After 3 months of survey data collection and 1,000 survey responses, the city council presentation showed a blank circumplex.
The mechanism: the mobile app survey platform exported PAQ column headers using title case — 'Pleasant', 'Vibrant', 'Eventful', 'Chaotic', 'Annoying', 'Monotonous', 'Uneventful', 'Calm'. soundscapy’s DataLoader.load_paqs() performs exact-match lookups against its expected lowercase attribute names: 'pleasant', 'vibrant', 'eventful', 'chaotic', 'annoying', 'monotonous', 'uneventful', 'calm'. Python string comparison is case-sensitive: 'Pleasant' != 'pleasant'. soundscapy did not find any of the 8 expected columns. With allow_missing=False (the default), load_paqs() raises a KeyError listing the missing column. The developer had set allow_missing=True at the start of the project to suppress errors during exploratory loading, intending to handle optional PAQ sub-scales. With allow_missing=True, soundscapy treats each missing attribute as legitimately absent and substitutes numpy.nan for all 8 PAQ values. The ISOPleasant and ISOEventful formulas then propagate NaN: any arithmetic operation involving NaN produces NaN. The resulting DataFrame had ISOPleasant=NaN and ISOEventful=NaN for every participant and every location. circumplex_plot() calls matplotlib.scatter(x, y) where both arrays are entirely NaN; matplotlib silently drops NaN points from the scatter plot without warning. The result was a pixel-perfect circumplex axis template with zero plotted points.
The annotated data loading pipeline with column normalization, NaN validation, and diagnostic utilities:
# Northfield Soundscapy Ltd. — soundscapy 0.7.1 column-name case fix
# soundscapy 0.7.1; Python 3.10; pandas 1.5
# 50-location urban soundscape survey; 20 participants per location; 1,000 responses
#
# Problem: survey export uses title-case PAQ column names
# 'Pleasant', 'Vibrant', 'Eventful', 'Chaotic',
# 'Annoying', 'Monotonous', 'Uneventful', 'Calm'
# soundscapy.DataLoader.load_paqs() expects lowercase
# allow_missing=True silently substitutes NaN for all 8 PAQ attrs
# ISOPleasant=NaN, ISOEventful=NaN for all 1,000 responses
# circumplex_plot() skips NaN points → blank canvas
# Fix: df.columns = df.columns.str.lower() before load_paqs()
import pandas as pd
import soundscapy as sspy
import numpy as np
PAQ_COLS = [
'pleasant', 'vibrant', 'eventful', 'chaotic',
'annoying', 'monotonous', 'uneventful', 'calm',
]
def normalize_columns(df: pd.DataFrame) -> pd.DataFrame:
"""Lowercase + strip column names; handle title-case survey exports."""
df = df.copy()
# 'Pleasant' → 'pleasant'; ' pleasant ' → 'pleasant'; 'PLEASANT' → 'pleasant'
df.columns = df.columns.str.lower().str.strip()
return df
def validate_paq_columns(df: pd.DataFrame) -> None:
"""Raise early if any PAQ column is missing or entirely NaN."""
missing = set(PAQ_COLS) - set(df.columns)
if missing:
raise ValueError(
f"Missing PAQ columns: {sorted(missing)}. "
f"DataFrame has columns: {list(df.columns)}. "
f"Check that column names are lowercase (soundscapy requires lowercase). "
f"Normalize with: df.columns = df.columns.str.lower()"
)
nan_cols = [c for c in PAQ_COLS if df[c].isna().all()]
if nan_cols:
raise ValueError(
f"PAQ columns are entirely NaN: {nan_cols}. "
f"This often means column names were not found by soundscapy's "
f"load_paqs() — check that allow_missing=False (the default) "
f"and that column names match exactly (case-sensitive)."
)
def load_paq_data_buggy(excel_path: str) -> pd.DataFrame:
"""BUGGY: allow_missing=True hides column name mismatch."""
df = pd.read_excel(excel_path)
# df.columns = ['LocationID', 'ParticipantID', 'Pleasant', 'Vibrant',
# 'Eventful', 'Chaotic', 'Annoying', 'Monotonous',
# 'Uneventful', 'Calm']
# BUG: allow_missing=True silently substitutes NaN for all 8 PAQ cols
# because soundscapy looks for lowercase names and doesn't find them.
# No KeyError, no warning, no log entry. Pipeline completes silently.
data = sspy.DataLoader.load_paqs(df, allow_missing=True) # BUG
return data
def load_paq_data(excel_path: str) -> pd.DataFrame:
"""FIXED: normalize column names before load_paqs(); validate after."""
df = pd.read_excel(excel_path)
# FIXED: normalize to lowercase before soundscapy lookup
df = normalize_columns(df)
# FIXED: validate PAQ columns are present BEFORE loading
validate_paq_columns(df)
# FIXED: allow_missing=False (default) raises KeyError if still missing
data = sspy.DataLoader.load_paqs(df, allow_missing=False)
# FIXED: validate ISOPleasant/ISOEventful are non-NaN after loading
coord_cols = ['ISOPleasant', 'ISOEventful']
if data[coord_cols].isna().any().any():
nan_locs = data[data[coord_cols].isna().any(axis=1)]['LocationID'].unique()
raise ValueError(
f"ISOPleasant or ISOEventful is NaN for {len(nan_locs)} locations: "
f"{list(nan_locs[:5])}{'...' if len(nan_locs) > 5 else ''}. "
f"Check that all 8 PAQ values are non-NaN for these locations."
)
return data
def diagnose_column_mismatch(df: pd.DataFrame) -> None:
"""
Print diagnostic comparing actual columns against soundscapy expected names.
Call this when circumplex_plot() shows an empty canvas.
"""
actual = set(df.columns.str.lower())
expected = set(PAQ_COLS)
found = expected & actual
missing_exact = expected - set(df.columns) # case-sensitive missing
missing_lower = expected - actual # still missing after lower()
print("=== soundscapy column diagnostic ===")
print(f"Actual columns: {sorted(df.columns.tolist())}")
print(f"Expected PAQ (lowercase): {sorted(PAQ_COLS)}")
print(f"Found (exact match): {sorted(expected & set(df.columns))}")
print(f"Missing (case-sensitive): {sorted(missing_exact)}")
print(f"Missing (after lower()): {sorted(missing_lower)}")
if missing_exact and not missing_lower:
print("DIAGNOSIS: Column names are present but have wrong case.")
print("FIX: df.columns = df.columns.str.lower()")
elif missing_lower:
print("DIAGNOSIS: Columns are genuinely absent from DataFrame.")
print("FIX: check paq_aliases or survey export configuration.")
else:
print("DIAGNOSIS: All PAQ column names are present and lowercase.")
Why allow_missing=True makes case-sensitivity invisible and why the circumplex grid looks correct with zero data points
Three factors combine to make this bug expensive. First, allow_missing=True is a reasonable setting during exploratory data work — a developer working with an incomplete survey might genuinely want to load partial PAQ data and compute provisional indices from available attributes. But once set in a production pipeline, it converts every column name mismatch (case, whitespace, prefix, encoding) from an immediate error into a silent NaN substitution. The gap between developer intent (“be lenient about optional fields”) and actual behavior (“silently accept complete data loss from column lookup failure”) is not documented in the function’s parameter description. Second, matplotlib.scatter() drops NaN points silently by design — this is the correct behavior for scatter plots where some data points are unavailable. The soundscapy circumplex axis grid (the circular boundary, the eight attribute labels, the ISO 12913-2 zone shading) is drawn independently from the data points; when all data points are NaN, the axis template renders completely, looking like a finished plot waiting for data rather than a broken output. A developer who has never seen a populated soundscapy circumplex has no visual reference for what a correct output looks like. Third, the survey collection ran for 3 months before the analysis pipeline was run against the full dataset, creating a long delay between the introduction of the bug (the first day of development) and its discovery (at the presentation deadline). Northfield Soundscapy Ltd.’s retainer engagement was 2.0h: 0.25h triage (run print(df.columns.tolist()); observe ['LocationID', 'ParticipantID', 'Pleasant', 'Vibrant', ...]; note title case); 0.5h root cause (soundscapy loads from lowercase names; 'Pleasant' != 'pleasant'; allow_missing=True returns NaN; test sspy.DataLoader.load_paqs(df, allow_missing=True) then print(data[['ISOPleasant','ISOEventful']].head()) → all NaN confirmed); 0.75h fix (add df.columns = df.columns.str.lower(); switch allow_missing=False; add column presence assertion; add post-load NaN assertion); 0.5h validation (reload full 1,000-response dataset; all 50 locations plot in correct circumplex quadrants; parks in pleasant/calm zone, transit hubs in eventful/chaotic zone; city council presentation updated with correct analysis; 2.0h total). Hours logged to HourTab with per-session breakdown.
Related retainer posts
- scikit-maad developer on retainer — scikit-maad 0.1.7; Python 3.9;
maad.sound.load()returns(s, fs)not(fs, s); developer unpacks asfs, s = maad.sound.load(); sample rate used as signal array and vice versa; all spectrogram computations receive scalar sample-rate value as audio; fix:s, fs = maad.sound.load(); 2.0h - scaper developer on retainer — scaper 1.6.0; Python 3.9;
sc.generate(audio_path, jams_path, reverb=0.1); reverb is SoX reverberance percentage (0–100) not normalized 0.0–1.0 fraction;reverb=0.1= 0.1% = anechoic; SED model F1 0.88 synthetic vs 0.42 real recordings; fix:reverb=30; 2.0h - audiomentations developer on retainer — audiomentations 0.33.0; Python 3.9;
AddBackgroundNoise(min_snr_in_db, max_snr_in_db); SNR relative to signal RMS; negative SNR values make background louder than signal; fix: verify SNR sign convention before training; 2.0h
Track retainer hours without a client portal
HourTab turns your time-tracker CSV into a public URL your client bookmarks. No login. No portal. CSV in, URL out.
See pricing →