如何在 pandas 中读取以空格分隔的值的文件 [英] How to read file with space separated values in pandas
本文介绍了如何在 pandas 中读取以空格分隔的值的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试将文件读入熊猫. 该文件具有以空格分隔的值,但空格数量不同 我试过了:
I try to read the file into pandas. The file has values separated by space, but with different number of spaces I tried:
pd.read_csv('file.csv', delimiter=' ')
但是它不起作用
推荐答案
添加delim_whitespace=True
参数,它比正则表达式要快.
add delim_whitespace=True
argument, it's faster than regex.
这篇关于如何在 pandas 中读取以空格分隔的值的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文