I am starting on with panda catagorical dataframes.
Let's say I have (1):
A B C
-------------
3 Z M
O X T
4 A B
I filtered the dataframe like that : df[ df['B'] != "X"]
So I would get as result (2):
A B C
-------------
3 Z M
4 A B
In (1) df['B'].cat.categories #would equal to ['Z', 'X', 'A']
In (2) df['B'].cat.categories #still equal to ['Z', 'X', 'A']
How to update the DF categories of all columns after this kind of filtering operation ?
BONUS : If you want to clean up the indexes after the filtering
df.reset_index()