Skip to content
Advertisement

Update Pandas df Given String Query

As a result of data introduced by users in the interface I have a string query-like.

JavaScript

Now I want to update a column of the df based on those conditions, assigning it a variable Z.

I don’t know if it can be done somehow with loc

JavaScript

Advertisement

Answer

I got the solution by myself:

JavaScript

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.eval.html

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement