Problem:
- When selecting only 1 value column in Pivot (long-to-wide), column names
were incorrectly formatted as 'FMA___('FMA', 'baseline')' instead of 'FMA___baseline'
- This occurred because pandas pivot_table() sometimes returns tuple column names
even for single value columns, but the code didn't handle this case
Root Cause:
- Line 112-127 in pivot.py assumed single value columns always have simple
string column names, without checking for tuples
- Multi-value column logic (line 129-145) correctly handled tuples with isinstance()
Solution:
- Add isinstance(col, tuple) check in single value column mode
- Extract pivot_value from tuple[1] if column name is a tuple
- Maintain backward compatibility for non-tuple column names
Testing:
- Single value column: FMA___ + tuple -> 'FMA___baseline' (fixed)
- Multiple value columns: Already working correctly (no change)
Impact: Fixes historical bug in Tool C Pivot feature
Major fixes:
- Fix pivot transformation with special characters in column names
- Fix compute column validation for Chinese punctuation
- Fix recode dialog to fetch unique values from full dataset via new API
- Add column mapping mechanism to handle special characters
Database migration:
- Add column_mapping field to dc_tool_c_sessions table
- Migration file: 20251208_add_column_mapping
UX improvements:
- Darken table grid lines for better visibility
- Reduce column width by 40% with tooltip support
- Insert new columns next to source columns
- Preserve original row order after operations
- Add notice about 50-row preview limit
Modified files:
- Backend: SessionService, SessionController, QuickActionService, routes
- Python: pivot.py, compute.py, recode.py, binning.py, conditional.py
- Frontend: DataGrid, RecodeDialog, index.tsx, ag-grid-custom.css
- Database: schema.prisma, migration SQL
Status: Code complete, database migrated, ready for testing