Data Cleaning With Python, Data Analysis, Dataframes Python, Marketing Analytics.
movies.drop(movies[movies['avg_rating'] > 5].index, inplace = True) Another way is to replace those values to max value i.e. 5 # Convert avg_rating > 5 to 5 movies.loc[movies['avg_rating'] > 5, 'avg_rating'] = 5 Ex4. In our second example we would see the date range falling out of expected values :