## cluster IMDB Ratings
import pandas as pd
import numpy as np
## determine conditions in function case_when
def case_when(row):
if (row['IMDB_Rating'] >= 0) & (row['IMDB_Rating'] <= 6):
return 'OK'
elif (row['IMDB_Rating'] > 6) & (row['IMDB_Rating'] <= 8):
return 'Good'
else:
return 'Excellent'
# apply case_when function
mydata['IMDB_cat'] = mydata.apply(case_when, axis=1)