Pandas does not recognise a column of floats when importing a csv

前端 未结 1 737
滥情空心
滥情空心 2021-01-06 20:11

I am trying to read the IMF statistics into a pandas dataframe:

import pandas as pd
df = pd.read_table(\"http://www.imf.org/external/pubs/ft/weo/2013/02/weod         


        
相关标签:
1条回答
  • 2021-01-06 20:58

    As mentioned by Jeff, this was a bug in <=0.12 (but is fixed in 0.13).

    In [11]: s = '''A;B
    1;2,000
    3;4'''
    
    In [12]: pd.read_csv(StringIO(s), sep=';', thousands=',')
    Out[12]: 
       A     B
    0  1  2000
    1  3     4
    
    [2 rows x 2 columns]
    
    In [13]: pd.version.version
    Out[13]: '0.13.0rc1-82-g66934c2'
    
    0 讨论(0)
提交回复
热议问题