We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

No Index

In Pandas, every DataFrame has an index:

df = pd.DataFrame(
    {"player": ["Sam", "Dario"], "level": [10, 20]},
    index=["closedai", "clawd"],
)
print(df)
#           player  level
# closedai     Sam     10
# clawd      Dario     20

The closedai and clawd labels on the left are index labels. Pandas lets you define custom indexes, reset them, and use them for selection.

Polars does not have a Pandas-style index. Here's the same data in Polars:

df = pl.DataFrame({"player": ["Sam", "Dario"], "level": [10, 20]})
print(df)
# shape: (2, 2)
# ┌────────┬───────┐
# │ player ┆ level │
# │ ---    ┆ ---   │
# │ str    ┆ i64   │
# ╞════════╪═══════╡
# │ Sam    ┆ 10    │
# │ Dario  ┆ 20    │
# └────────┴───────┘

No index labels at all. Rows are identified by position, and any other kind of identifier that you want to add should go in a normal column.

Why No Index?

The Pandas index exists for complicated historical reasons. It can be convenient, but it's also a common source of confusion, and it creates extra rules around filtering, alignment, and joins.

Polars takes the simpler route: no hidden row labels. That means you have to be more explicit about what you want when joining and filtering data, which is usually a good tradeoff.