Train.csv cannot convert string to float

Hello all, I’m working on the training (train.csv) files and am having an issue. I am running on Jupyter Notebooks with a Mac and Python 2.7. I can get the data imported and can even “print data”, the following comes through. It looks like I’m picking up the first row which is unlike the tutorial. for row in csv_file_object: data.append(row) print data [[‘PassengerId’ ‘Survived’ ‘Pclass’ …, ‘Fare’ ‘Cabin’ ‘Embarked’] [‘1’ ‘0’ ‘3’ …, ‘7.25’ ” ‘S’] [‘2’ ‘1’ ‘1’ …, ‘71.2833’ ‘C85’ ‘C’] …, [‘889’ ‘0’ ‘3’ …, ‘23.45’ ” ‘S’] [‘890’ ‘1’ ‘1’ …, ’30’ ‘C148’ ‘C’] [‘891’ ‘0’ ‘3’ …, ‘7.75’ ” ‘Q’]] data = np.array(data) number_passengers = np.size(data[0::,1].astype(np.float)) ValueError Traceback (most recent call last) in () —-> 1 number_passengers = np.size(data[0::,1].astype(np.float)) ValueError: could not convert string to…


Link to Full Article: Train.csv cannot convert string to float

Pin It on Pinterest

Share This

Join Our Newsletter

Sign up to our mailing list to receive the latest news and updates about homeAI.info and the Informed.AI Network of AI related websites which includes Events.AI, Neurons.AI, Awards.AI, and Vocation.AI

You have Successfully Subscribed!