clean_columns
clean_columns(df)Makes a raw results table safe to analyse: tidy, unique column names and numbers only.
Column names are stripped, internal spaces become underscores, other special characters are removed and duplicates are numbered (Signal, Signal_1). Columns with no numeric values (text or completely blank) are dropped; stray text cells in a numeric column become missing values, which validation later drops as invalid rows.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| df | pd.DataFrame | The table as read from the file. | required |
Returns
| Name | Type | Description |
|---|---|---|
| tuple | pd.DataFrame | The cleaned numeric DataFrame, the names of the dropped text |
| list[str] | columns (blank columns are dropped without being listed), and the number of text cells turned into missing values. |
Examples
df, dropped, n_bad = clean_columns(pd.read_csv("results.csv"))