Home > Software design >  Pandas convert column to float with a $symbol
Pandas convert column to float with a $symbol

Time:12-29

I have an object column(item_price) and I want to convert it in a float column but I can´t not do it with the symbol $...can anyone help me??

Thanks in advance

enter image description here

CodePudding user response:

Use:

chipo['item_price'] = chipo['item_price'].str.lstrip('$')

and then convert it float.

CodePudding user response:

Try this:

chipo['item_price'] = chipo['item_price'].str.replace('$', '', regex=False).astype(float)
  • Related