Home > Back-end >  How to execute a column that has a multi word label?
How to execute a column that has a multi word label?

Time:08-03

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**

CodePudding user response:

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")

CodePudding user response:

first: check if you uploaded inp0 like that :

inp0.Content= sns.load_dataset("data")

second: try it without command .set (in the second line), you can

  • Related