description: python assign or set value if conditions match
python assign or set value based on conditions
1 | import pandas |
filter the data with condtion 1
1 | tmp = data[data["a"] == 1] |
filter the data with condition 2
1 | tmp = tmp[tmp["b"] == 2] |
get the index of the data
1 | indexes = tmp.index |
change values by indexes and column name
1 | data._set_value(indexes, 'test', 888888) |
more on search4fan.github.io