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

ValueError: could not convert string to float: 's' (kaggle help please)

**I am trying to use z scores to reguralize the data and remove the null values out of kaggle songs.
Here is my code:

  # Then we calculate the standard deviation
  crab = 0
  
  for dog in column:
      crab += (float(dog) - average)**2
  crab /= n
  crab = math.sqrt(crab)
  # Then when we update the values
# for column in data.columns:
#     s = sum(column) / len(column)
#     u = for standard in columnlength(column)
#     for elements in column:
# print(data.shape) 

The bottom part is what i am having trouble with, and here is the link to my code and data: https://colab.research.google.com/drive/1u5_lDgXCQOyt_1HYxUERWtgOtBNNPwdY?usp=sharing

Error: ValueError: could not convert string to float: ‘s’

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 :

Your issue is here

for dog in column:
  crab += (dog - average)**2

"average" is of type float and "dog" is of type string. Try casting dog to a float like this and see if it works:

for dog in column:
  crab += (float(dog) - average)**2
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