import pandas as pd
What I expected to happen:
Whenever I submit, it says that “titanic is longer than we expected”, but may i know why using my method is wrong?
Thank you for the help!
You are not actually saving the changes you make to
The above makes changes to titanic by dropping rows, but you are not saving those changes back into that variable.
titanic = titanic.dropna(axis="rows")
Or Another way would be
Both solutions are good.
Note for the original poster.
The default behaviour of
dropna may change from version to version of Pandas. Always read the documentation whenever in doubt.
A function can do one or more of the following:
- make changes to the data in place
- return a new object
- return None