If one row in two columns contain the same string python pandas

Viewed 1606

I have a dataframe looking like this:

    id      k1        k2         same
    1    re_setup    oo_setup   true
    2    oo_setup    oo_setup   true
    3    alerting    bounce     false
    4    bounce      re_oversetup   false
    5    re_oversetup    alerting   false
    6    alerting_s  re_setup   false
    7    re_oversetup    oo_setup   true
    8    alerting    bounce     false

So, I need to classified rows where string 'setup' is contained or not.

And simple output would be:
    id      k1        k2         same
    1    re_setup    oo_setup   true
    2    oo_setup    oo_setup   true
    3    alerting    bounce     false
    4    bounce      re_setup   false
    5    re_setup    alerting   false
    6    alerting_s  re_setup   false
    7    re_setup    oo_setup   true
    8    alerting    bounce     false

I've tried something with this, but as I expact, I have error with selecting multiple columns.

data['same'] = data[data['k1', 'k2'].str.contains('setup')==True]
2 Answers
Related