Vectorized pd.str.replace

Viewed 32

I've got two dataframes

One with the rule -different rules, depending on some conditions

        Value 1     Value2
Cond1   x> 2.5     x>5
Cond2   2.5>x>1    5>x>0

And one with different values of x

   Value1   Value2
      0       6
      2       3

And I want to use the dataframe of condition in order to evaluate the values of x. I can use a loop, like

for value in Data_value : 
    Data_evaluate.str.replace("x",str(Data_value))

but it can take lot of time since there are lot of values of x.

I tried also to use directly the method

Data_evaluate.str.replace("x",Data_value.apply(str))

but it doesn't work, since it supports only string, and not Dataseries of string.

Is there a way to vectorize this problem ?

Thanks

0 Answers
Related