I am doing a Kaggle tutorial for Titanic using the Datacamp platform.
I understand the use of .loc within Pandas - to select values by row using column labels...
My confusion comes from the fact that in the Datacamp tutorial, we want to locate all the "Male" inputs within the "Sex" column, and replace it with the value of 0. They use the following piece of code to do it:
titanic.loc[titanic["Sex"] == "male", "Sex"] = 0
Can someone please explain how this works? I thought .loc took inputs of row and column, so what is the == for?
Shouldn't it be:
titanic.loc["male", "Sex"] = 0
Thanks!