I have a data frame of about 100 rows all with different values that looks something like the following:
Data frame 1:
| Index | Values |
|---|---|
| 0 | Celery |
| 1 | Beetroot |
| 2 | Pineapple |
I also have another data frame that looks something like this:
Data frame 2:
| Index | Values |
|---|---|
| 0 | Apple |
| 1 | Carrot |
| 2 | Pineapple |
| 3 | Celery |
| 4 | Beetroot |
And want to modify all the values in Data frame 1 to 'Other' In data frame 2 like:
| Index | Values |
|---|---|
| 0 | Apple |
| 1 | Carrot |
| 2 | Other |
| 3 | Other |
| 4 | Other |
I could do this individually for every value but there are too many, and am a bit stuck on how to turn this into a loop:
Modifying beetroot to 'Other'
data_frame2 = data_frame2.replace([Beetroot], 'Other')