Python: Convert string (in scientific notation) to float

前端 未结 4 1943
小鲜肉
小鲜肉 2020-12-09 09:42

I\'m trying to import a large .csv file containing text and numbers using genfromtxt in numpy. I\'m only interested in two columns. I have most of the import sorted out wit

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-09 10:16

    MAybe that will be helpful for anybody, I had similar problem and I've found on stackoverflow about applying pandas to_numeric to DataFrame columns including replacing commas with dots

    import re
    import pandas as pd
    atw[cc] = pd.to_numeric(atw[cc].apply(lambda x: re.sub(',', '.', str(x))))
    

提交回复
热议问题