Use the mask method on a DataFrame to make all the values in rows with movies that were made from 2010 onward missing. Any movie that originally had a missing value for title_year is also masked:
>>> movie.mask(criteria).head()
Notice how all the values in the third, fourth, and fifth rows from the preceding DataFrame are missing. Chain the dropna method to remove rows that have all values missing:
The equals method is telling us that they aren't equal. Something is wrong. Let's do some sanity checking and see if they are the same shape:
>>> movie_mask.shape == movie_boolean.shape True
When we used the preceding mask method, it created many missing values. Missing values are float data types so any previous integer column is now a float. The equals method returns False if the data types of the columns are different, even if the values are the same. Let's check the equality of the data types to see whether this scenario happened:
It turns out that a couple of columns don't have the same data type. Pandas has an alternative for these situations. In its testing module, which is primarily used by developers, there is a function, assert_frame_equal, that allows you to check the equality of Series and DataFrames without also checking the equality of the data types:
from pandas.testing import assert_frame_equal >>> assert_frame_equal(movie_boolean, movie_mask, check_dtype=False)