1、使用read_csv读取数据null显示NaN
import pandas as pd
from io import StringIO
data = u'strings,numbers\nfoo,1\nbar,2\nnull,3'
print(pd.read_csv(StringIO(data)))
输出:
strings numbers
0 foo 1
1 bar 2
2 NaN 3
2、使用read_csv读取null数据显示为字符串null
import pandas as pd
from io import StringIO
data = u'strings,numbers\nfoo,1\nbar,2\nnull,3'
pd.read_csv(StringIO(data), converters={'strings' : str})
#或
pd.read_csv(StringIO(data), na_filter=False)
#或
df = pd.read_csv(io.StringIO(data), keep_default_na=False)
strings numbers
0 foo 1
1 bar 2
2 null 3