Problem : Relationship between the length of a film that lasts between 60 and 200 minutes and its average rating

I want to display, with a curve, the relationship between the length of a film that lasts between 60 and 200 minutes and its average rating on IMDb :

movies['duree'] = movies[(movies.duree<200) | (movies.duree>60)] #ERROR is HERE
sns.relplot(x=movies['duree'], y="averageRating", kind='line', data=movies)

TypeError: ‘<‘ not supported between instances of ‘str’ and ‘int’

enter image description here

Answer

You are not making the conversion correctly, for example:

import pandas as pd
import seaborn as sns

movies = pd.DataFrame({
    'duration':["95 min","118 min","143 min","89 min","91 min","221 min"],
    "averageRating":[6.8,5.3,6.4,7.8,4.6,7.7],
    "listed_in":['A','B','C','D','E','F']
})

If I run your code I get the same error. Hard to trouble shoot unless you provide the full data frame, or try to locate where the string conversion failed. If I do this on the example, it works, and note, you subset the dataframe and pass it to plot:

movies['duree'] = movies['duration'].str.slice(0,-4).astype('int')
sns.relplot(x='duree', y="averageRating", kind='line', 
data=movies[(movies.duree<200) | (movies.duree>60)])