0

that I know this was working for me last time I ran my script. but it looks like is not anymore. I have a scraping module which returns a dict, at my main script im running the scraping and assigning values . but now im getting this error about cannot convert a the string value to a float ( should i set the column to string from the very beginning ? )

This is the error

dataset.at[index,'UserPhotoUrl'] = scrapedData['usernamePhotoLink']

ValueError: could not convert string to float: 'https://instagram.fhex4-1.fna.fbcdn.net/v/t51.2885-19/s150x150/81572390_579207132636171_1735861275205828608_n.jpg?_nc_ht=instagram.fhex4-1.fna.fbcdn.net&_nc_ohc=EfweZRX7mn8AX8kKx7e&oh=b7cb7aaf3ee583604e4a40cd7b23447f&oe=5EA1B8F7'

lorenzo gonzalez
  • 1,894
  • 4
  • 14
  • 18
  • It might be worth taking a look at [How to make good pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) and providing a [mcve] with sample input, sample output, and a reproducible amount of code – G. Anderson Jan 15 '20 at 22:25

2 Answers2

0

did you try setting the scrapedData explicitly to a string?

dataset = pd.read_csv(openFilename, delimiter = ',',encoding = my_encoding, dtype={'UserPhotoUrl': str, 'PostPhotoUrl': str})
Shenanigator
  • 1,036
  • 12
  • 45
0

Well guys, I did find the solution. doesn't look as elegant though .

dataset = pd.read_csv(openFilename, delimiter = ',',encoding = my_encoding)
dataset['UserPhotoUrl'] = " "
dataset['PostPhotoUrl'] = " "
dataset.astype({'UserPhotoUrl': 'str'})
dataset.astype({'PostPhotoUrl': 'str'})

Had to set at the very beginning forcing to str.

lorenzo gonzalez
  • 1,894
  • 4
  • 14
  • 18