I am getting some error message while performing encoding

The code is working, but i dont know why above message is comming. Can someone exaplane.

This is also known as chained assignments. As it is working, probably you can ignore the warning, also you might want to stop showing those error warnings. The way to do so is just to include and run the code below.

pd.options.mode.chained_assignment = None  # default='warn'

This post might be helpful,