I need to update the values of a column (X) in correspondance with certain values ('v') of another column Y with values from another column (Z) times some numbers and then cast the obtained column to int:
In pandas the code is as follow:
df.loc[df["Y"] == "v", "X"] = ( df.loc[df["Y"] == "v", "Z"] * 1.341 * 15).astype(int)
In polars i'm able to select values (e.g. nulls) from a column and replace them with values from another column:
df=df.with_columns( pl.when(df['col'].is_null()) .then(df['other_col']) .otherwise(df['col']) .alias('alias_col'))
but i'm stuck at nesting the call to the (modified) third column.
Any help would be very much appreciated!