Flag skewed numeric columns in a pandas DataFrame by absolute skewness
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: easy
Interview Round: Other
Write `skew_flag_report(df: pd.DataFrame) -> pd.DataFrame` that computes `Series.skew()` for each numeric column of `df` and classifies its absolute value:
- `|skew| < 0.5` is 'Symmetric'.
- `0.5 <= |skew| < 1` is 'Moderately skewed'.
- `|skew| >= 1` is 'Highly skewed'.
The report follows these rules:
- `skew` uses pandas' bias-corrected convention, which equals `scipy.stats.skew(x, bias=False)` and differs from SciPy's default `bias=True`.
- The columns are exactly `['column', 'skew', 'abs_skew', 'shape']` in that order, with dtypes `column=object`, `skew=float64`, `abs_skew=float64` and `shape=object`.
- There is one row per numeric column. Non-numeric columns are skipped; do not try to convert them to numbers.
- Rows are sorted by `abs_skew` descending, then `column` ascending, followed by `reset_index(drop=True)`.
```hint Columns and dtypes
Select the numeric columns explicitly before computing anything, and check the dtype of every output column at the end, since text columns can come back with a dtype other than `object`.
```
### Constraints & Assumptions
- The test input is a fixed DataFrame with four numeric columns and one string column.
- The result is compared with `pandas.testing.assert_frame_equal`, so column order, dtypes, row order and the index all have to match.
### What a Strong Answer Covers
- Selecting only the numeric columns and computing pandas' bias-corrected skewness for each.
- A classification that puts the boundary values 0.5 and 1 in the right band.
- The exact column order and dtypes, the two-key sort and a clean index.
- What the bias-corrected coefficient is and how it differs from SciPy's default.
- Columns where skewness cannot be computed.
### Follow-up Questions
- How would you handle a column with fewer than 3 non-null values?
- Should boolean columns count as numeric here, and how would you control that?
- Why can the 0.5 and 1 thresholds mislead on a column with only a few dozen rows?
Overview: Write a pandas function that computes bias-corrected skewness for every numeric column, labels each column as symmetric, moderately skewed or highly skewed, and returns a sorted report. It tests column selection, threshold boundaries, exact output dtypes and the difference between skewness conventions.