There is a table:
df = pd.DataFrame({"A": ["foo", "foo", "foo", "foo", "foo", ... "bar", "bar", "bar", "bar"], ... "B": ["one", "one", "one", "two", "two", ... "one", "one", "two", "two"], ... "C": ["2017", "2017", "2018", "2017", ... "2018", "2017", "2018", "2017", ... "2017"], ... "D": [1, 2, 2, 3, 3, 4, 5, 6, 7]}) It is necessary to put down in the E column the values ββ'Yes' if in the row A 'foo' and 'No' if 'bar'
I try to iterate over the column as follows:
for x in df['A']: if 'foo' in x: df'['E'] = 'Yes' But in this form, as I understand it, one value will be put on the entire column 'E'. How to do it right?
That is, you need not just when the value matches, but when a certain object enters the string, you must fulfill the condition