DEV Community

Patryk P
Patryk P

Posted on

(Im)mutability of polars DataFrame

Hey guys, there is one thing that I don't understand in polars. Everybody says that polars dataframes are immutable. However I can perform these operations without changing id of the object:

import polars as pl

my_df = pl.DataFrame({"a": [1, 2, 3], "b": [2, 3, 4]})
print(id(my_df))

my_df[0, "a"] = 10

print(my_df)
print(id(my_df))  # it's the same id
Enter fullscreen mode Exit fullscreen mode

The modified value is changed, however the id is the same. Why?

Top comments (0)