如何在 pandas 中读取带有空格分隔值的文件 [英] How to read file with space separated values in pandas

查看:78
本文介绍了如何在 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆