I have a dictionary like this
d = {"animal": ["cat", "dog", "turtle"], "fruit" : ["banana", "apple"]}
and a df:
+-----------+
|some_column|
+-----------+
| banana|
| cat|
| apple|
| other|
| null|
+-----------+
Id like to get this as output:
+-----------+
|some_column|
+-----------+
| fruit|
| animal|
| fruit|
| other|
| null|
+-----------+
I know that if i had a dictionary like this
{"apple" : "fruit", "banana": "fruit", [···]}
i could use df.na.replace, and of course i can work through my given dictionary and change it to something like this.
But is there a way of getting my desired output without changing the dictionary?