artempozdniakov / spotify_eda_and_recomendation_engine

Jupyter Notebook with Spotify data EDA and Songs Recommendation Engine realization.
https://www.kaggle.com/artempozdniakov/spotify-data-eda-and-music-recommendation
0 stars 0 forks source link

could not convert string to float #1

Open alvinamalindra opened 2 years ago

alvinamalindra commented 2 years ago

Hello, I'm stil struggling with this issue for a while when trying to run:

recommender.get_recommendations(,5)

ValueError                                Traceback (most recent call last)
<ipython-input-35-c7a5311a9723> in <module>
----> 1 recommender.get_recommendations('good 4 u',5)

<ipython-input-33-6cba4106171a> in get_recommendations(self, song_name, amount)
     20                 #indeces of non-numerical columns
     21                 if not col in [3, 5, 7, 8]:
---> 22                     dist = dist + np.absolute(float(song[col]) - float(r_song[col]))
     23             distances.append(dist)
     24         res_data['distance'] = distances

ValueError: could not convert string to float: '40,162,559'

I'm using a different dataset anyway. Can you help me with this?

artempozdniakov commented 2 years ago

Hello, the problem is, that you have commas in your string. You should remove them in order to convert it to a float