Python dataframe = Replace values in column string with values from another dataframe

I have the following dataframe (RuleDF) with a column which contains a string.
Inside the string are some values (parameters) which shall be replaced
eg. param1 and param2

Rule_ID Rule_Value
R-123 column1 > param1 and column2 > param2
R-456 column1 > param1
... ...

There is another Dataframe (RuleMapDF) with the mapping:
Rule_ID Rule_Param Param_Value
R-123 param1 100
R-123 param2 200
R-456 param1 100

The result of the replacement will be something like this:
Another option is to have a new column with the replaced string

Rule_ID Rule_Value
R-123 column1 > 100 and column2 > 200
R-456 column1 > 100
... ...

I appreciate any ideas. Thank you.



from Recent Questions - Stack Overflow https://ift.tt/35LQAAC
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)