Explanation for why supposedly similar codes gives different result

Here is my code at the beginning of the mission Conditional Plots…Introduction to the Data set.

titanic.drop(["Name", "Ticket", "Cabin", "PassengerId"], axis = 1, inplace = True)

And here is DQ’s solution(answer) code:
cols = ['Survived', 'Pclass', 'Sex', 'Age', 'SibSp', 'Parch', 'Fare', 'Embarked']
titanic = titanic[cols].drop

Can someone explain this…
Many thanks.

would be nice if you share the screen link too

But as far as i can understand for both codes. What you’re doing is selecting the columns required and then drop every NaN value. While (again as fas as i understand reading the code) what you were asked to do was to select the columns that you don’t need and drop them.

Those two are completely different, specially because you might have deleted some rows that had NaN values when you can easily fill them with different methods, and droping those rows might change everything in whatever you’re doing

Assigning back to titanic or using inplace = True solves it.

titanic.dropna(how='any', inplace=True)