How to convert bytes data into a python pandas dataframe?

前端 未结 3 1046
刺人心
刺人心 2021-01-04 02:00

I would like to convert \'bytes\' data into a Pandas dataframe.

The data looks like this (few first lines):

    (b\'#Settlement Date,Settlement Peri         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-04 02:37

    I had the same issue and found this library https://docs.python.org/2/library/stringio.html from the answer here: How to create a Pandas DataFrame from a string

    Try something like:

    from io import StringIO
    
    s=str(bytes_data,'utf-8')
    
    data = StringIO(s) 
    
    df=pd.read_csv(data)
    

提交回复
热议问题