我发现pandas read_csv方法比numpy loadtxt更快。不幸的是,现在我发现自己处于一种不得不返回numpy的状态,因为loadtxt可以选择设置comments=['#','@']
。据我所知,帮助网站上的Pandas read_csv方法只能使用一个注释字符串,如comment='#'
。任何建议或解决方法,可以使我的生活更轻松,并使我不会回到numpy?另外为什么熊猫不支持多个评论指标?为什么pandas read_csv不支持多个注释(#,@,...)?
# save this in test.dat
@ bla
# bla
1 2 3 4
小例子:
# does work, but only one type of comment is accounted for
df = pd.read_csv('test.dat', index_col=0, header=None, comment='#')
# does not work (not suprising reading the help)
df = pd.read_csv('test.dat', index_col=0, header=None, comment=['#','@'])
# does work but is slow
df = np.loadtxt('test.dat', comments=['#','@'])
[MCVE](http://stackoverflow.com/help/mcve) – Kartik
请包括一些测试数据以及。此外,没有任何代码使用熊猫... – darthbith