Summery of the report: Wrong method description on the course.
Course URL: You can find it here.
Steps to Reproduce: N/A
Fix or Workaround:
This is the part of the instructions:
# here our .where() function replaces latitude values less than 40 with NaN values
restaurants['latitude'] = restaurants['latitude'].where(restaurants['latitude'] < 40, np.nan)
# here our .where() function replaces longitude values greater than -70 with NaN values
restaurants['longitude'] = restaurants['longitude'].where(restaurants['longitude'] > -70, np.nan)
# .sum() counts the number of missing values in each column
restaurants.isna().sum()
The first two comments are actually wrong:
# here our .where() function replaces latitude values less than 40 with NaN values
# here our .where() function replaces longitude values greater than -70 with NaN values
The commands demonstrated are actually keeping the values with latitude and longitude less than and greater than 40 and -70, respectively and replacing everything else with NaN values.
You can find the official documentation here.
DataFrame.where( *cond* , *other=NoDefault.no_default* , *inplace=False* , *axis=None* , *level=None* , *errors='raise'* , *try_cast=NoDefault.no_default* )
Replace values where the condition is False.Where cond is True, keep the original value. Where False, replace with corresponding value from other.