I want to iterate and modify the values under a column 'B', which have repeated values.
So for example if my data frame is like
A B
1 null,null
2 null
3 null,null,null
4 null,apples
5 null,apples,null
6 null,apples,apples
Now I want to modify this so that a new column C is created in the data frame, depending on the column values from B. It will do the following:
- Replace all the multiple "Nulls" with just a single "null" value
- If there is an occurrence of the word apples, then we store "apples" in the new column instead of null.
Desired output-
A B C
1 null,null null
2 null null
3 null,null,null null
4 null,apples apples
5 null,apples,null apples
6 null,apples,apples apples
nullstring orNonein your column?