Good pandas and polars code should also be written in an immutable way...
Agree. While it is common to see code like these pandas examples, it is very possible to write these manipulations so that they return a new frame or view without changing the inputs.
Good python code can exist, but python makes it so easy to write bad code that good python rarely exists.