Customizing the separator in pandas read_csv

心已入冬 提交于 2019-12-03 05:29:54
Ted Petrou

Yes, you can use a simple regular expression like sep='\s+' to denote one or more spaces.

You can also use the parameter skipinitialspace=True which skips the leading spaces after any delimiter.

You can directly use delim_whitespace

import pandas as pd df = pd.read_csv('myfile.dat', delim_whitespace = 1 )

One thing I found is if you use a unsupported separator. Pandas/Dask will have to use the Python engine instead of the C engine. This is a good deal slower.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!