pandas习题 051:将字符串数据读取到 DataFrame
编码题)有以下逗号隔开和空格隔开的字符串数据,如何将它读取为 DataFrame ?
data = ‘’’
a,b,c
1,3,4
2,4,5
‘’’
data2 = ‘’’
a b c
1 13 214
2 4 15
‘’’
Python 代码如下:
import pandas as pd
import io
data = '''
a,b,c
1,3,4
2,4,5
'''
df = pd.read_csv(io.StringIO(data