Logo

dev-resources.site

for different kinds of informations.

(Im)mutability of polars DataFrame

Published at
10/31/2024
Categories
polars
Author
patrykp
Categories
1 categories in total
polars
open
Author
7 person written this
patrykp
open
(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?

Featured ones: