eschutho opened a new pull request, #41344:
URL: https://github.com/apache/superset/pull/41344
### What was the deprecation warning?
```
FutureWarning: Series.__getitem__ treating keys as positions is deprecated.
In a future version, integer keys will always be treated as labels
(consistent with DataFrame behavior). To access a value by position,
use `ser.iloc[pos]`
```
Fired from `superset/models/core.py` in `Database.post_process_df`. The
inner helper `column_needs_conversion` used `df_series[0]` to peek at the
first element. When the Series index doesn't contain `0` as a label (e.g.
after a filter like `df[df.col > value]`), pandas raises this FutureWarning
and will raise a `KeyError` in a future pandas version.
### What was changed?
`df_series[0]` → `df_series.iloc[0]` in `post_process_df`.
`iloc` is unconditionally positional — it always means "first element"
regardless of the index labels.
### No behavior change
The empty-check (`not df_series.empty`) guards against `IndexError` on
`.iloc[0]`. The conversion logic is unchanged; only the access method
corrects the deprecation.
### Test plan
- Added `test_post_process_df_non_zero_based_index` in
`tests/unit_tests/models/core_test.py`. Constructs a DataFrame with a
non-zero-based index (by filtering rows so index is `[1, 2]` not `[0, 1,
2]`) and asserts `post_process_df` correctly JSON-serializes list columns.
- `pytest
tests/unit_tests/models/core_test.py::test_post_process_df_non_zero_based_index`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]