Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to execute a column that has a multi word label?

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading