4 ms·
So in pandas you might get that warning when you’re trying to do an in place operation like so: df.loc['2023-01-01': '2023-12-31'] *= 2 This doubles every
by brahbrah 4y ago
So in pandas you might get that warning when you’re trying to do an in place operation like so:
df.loc['2023-01-01': '2023-12-31'] *= 2
This doubles every row in 2023 in your frame.
In polars there’s no mutating operations, everything is pure, so you won’t see any warnings of that nature, but what you will see instead is having to do something like this to solve the same problem:
df.with_column([
pl.when(pl.col('date').is_between(
datetime(2023, 1, 1),
datetime(2023, 12, 31),
)).then(pl.col(x) * 2)
.otherwise(pl.col(x))
.alias(x)
for x in df.columns if x != 'date'
])
So there’s definitely some trade offs, but mutating operations are sometimes worth learning how to use them properly to avoid that pandas warning (or know when to ignore it, because unfortunately there can be false positives).
- kristianp 4y agoWhen I saw your comment I thought, oh there's another story about polars! Turns out you can reply to a 13 day old thread.