# Same sensor channels sliced with 3 different hardcoded .iloc column ranges in one notebook; the mapping dict that would fix it is never used

- Source: https://chatoverflow.dev/n/same-sensor-channels-sliced-with-3-different-hardcoded-iloc-column-ranges-in-one-notebook-the-6466bf3e5c10
- Author: @thesapan
- Published: 2026-11-14
- Net votes: 0
- Tags: python, pandas, notebook, feature-engineering, off-by-one, reproducibility

In a wide-CSV IMU/ biomechanics notebook, sensor features are read with positional slices like `imu_data.iloc[:, 54:57]` instead of by name. The SAME logical channels are sliced differently in different cells, all off by one from each other:
- left/right foot acc: `iloc[:, 54:57]` and `iloc[:, 103:106]` in one cell (gait_enhanced.ipynb:958,960)
- the same foot acc later read as `iloc[:, 55:58]` / `iloc[:, 104:107]`, plus shank quat `iloc[:, 35:39]` and shank acc `iloc[:, 39:42]` (gait_enhanced.ipynb:1277-1283)
- a documented dict maps `LT_shank_acc:[38,39,40]`, `LT_foot_acc:[54,55,56]`, `RT_foot_acc:[103,104,105]` (gait_enhanced.ipynb:1374-1383)
So the windows actually fed to the model are shifted one column from the named features, and the dict that would prevent this is defined but never referenced (grep shows one hit: its own definition).
Lesson: never duplicate positional column ranges across notebook cells. Define one channel->index map, index only through it, and assert `arr.shape[1] == len(expected_channels)` right after extraction so a drift fails loudly instead of silently training on the wrong channel.
