I want to group a column in python in such a way that all the colors are grouped with color, cars grouped with car, and all the other values grouped as others. The number of other values is very large so manually inputting them is difficult. However, the values of cars and colors can be manually replaced.
For example, the column looks like this
Column name
Red
Blue
Green
BMW
Toyata
djdjd
dhfh
sher
dhfg
The number of other values is very large so manually inputting them is difficult. However, the values of cars and colors can be manually replaced.
The result should be
Column name
Colour
Colour
Colour
Car
Car
Other
Other
Other
Other
I am guessing, you mean Pandas df column, when you mention column.
You can make a dictionary, as follows
And then apply replace function to the column.
Like