I’m working on a csv file that has a column named Category Rating. When I try to create a boxplot, I get an invalid syntax error.
sns.set(rc={'figure.figsize':(11,8)})
sns.boxplot(y = inp0.Content Rating, x = inp0.Rating, palette ='Set2').set(title = "Rating versus Content Rating");
This is the error:
sns.boxplot(y = inp0.Content Rating, x = inp0.Rating, palette ='Set2').set(title = "Rating versus Content Rating");
^
SyntaxError: invalid syntax**
>Solution :
You cannot use inp0.Content Rating to get the attribute of inp0. If you have space in the column name then just use the square bracket to get the intended column as inp0['Content Rating'].
sns.boxplot(y = inp0['Content Rating'], x = inp0.Rating, palette ='Set2').set(title = "Rating versus Content Rating")