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