jiayuasu opened a new pull request, #846:
URL: https://github.com/apache/sedona-db/pull/846
Pandas-style bracket indexing on `DataFrame`, dispatching to the existing
`select` / `filter` / `col` paths landed in earlier PRs (#807, #823, #832,
#835).
This is a small follow-on PR continuing Phase P1/P2 of #791. Pure Python
sugar — no new Rust code.
## What's new
```python
df["x"] # → Expr(col("x"))
df[["x", "y"]] # → DataFrame.select("x", "y")
df[df["x"] > 0] # → DataFrame.filter(col("x") > 0)
df[(df["x"] + df["y"]) > 30] # composes cleanly with operator overloads
df[df["x"] > 1][["y"]] # chain: filter → project
```
Row-position indexing (ints, slices, `.loc`, `.iloc`) is intentionally
**not** supported and raises `TypeError` with a message pointing at the three
supported forms. SedonaDB has no row-ordering or index concept in this scope;
the non-goal is documented in
[#791](https://github.com/apache/sedona-db/issues/791).
## Note on `df["x"]` return type
For now, `df["x"]` returns an `Expr` (a column reference). A `Series`
wrapper is planned for the next phase — when that lands, `df["x"]` will start
returning `Series` instead and `Expr` will fall back to an internal escape
hatch. The compose-with-operators idiom continues to work either way because
`Series` will share the same operator surface as `Expr`.
## Test plan
10 tests in `tests/expr/test_dataframe_getitem.py`:
- **Positive**: string lookup → Expr (exact `repr()`); list projection
(two-col, single-col, reorder); bool-Expr filter; arithmetic compose;
filter-then-project chain.
- **Errors**: list with non-string element → `TypeError`; int → `TypeError`;
slice → `TypeError`.
All 10 pass locally. No regressions in existing tests; doctests + `ruff
format` + `ruff check` all clean.
--
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]