Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting parse error in plotting "Expected end of text, found '$'"

I was trying to plot the two columns with artist name and loudness from a spotify data. but while trying to do the same I am getting error

ValueError: Joey Bada$$ ^ Expected end of text, found '$' (at char 9), (line:1, col:10) while inspecting I found there are data rows with the values like the "Joey Bada$$" in the data rows. Can some one please help me? whether the regex concept can be used in order to avoid this issues. used code is given below;

plt.figure(figsize=(30,10))
plt.scatter(spotifydata['artist_name'],spotifydata['loudness'] )
plt.show()
like image 836
Ddevil Prasad Avatar asked Nov 20 '25 04:11

Ddevil Prasad


1 Answers

Matplotlib interprets everything between $ signs as math text. As far as I know this can't be switched off.

If you want to remove the $$ signs:

plt.scatter(spotifydata['artist_name'].str.replace('\$\$',''), spotifydata['loudness'])

if you want to keep the $$ signs:

plt.scatter(spotifydata['artist_name'].str.replace('\$\$','\\$\\$'), spotifydata['loudness'])
like image 198
Stef Avatar answered Nov 22 '25 04:11

Stef



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!