Pandas read_csv读取文本文件速度测试
目录
问题发现
在将Pandas升级到1.0.x版本后发现read_csv函数相比之前的版本,在读取文本文件时速度大幅变慢。
本文根据这个问题做一个测试记录问题情况,寻找有效的解决方法。
一、测试条件
分别在Pandas 1.0.3、0.23.4、0.24.1、0.25.3版本下测试,pd.read_csv函数读取144MB的txt文件的速度。
1.测试环境
基本运行平台:Windows 7 64位,Python 3.7.7。
详细测试配置:
- Pandas 1.0.3
INSTALLED VERSIONS
------------------
commit : None
python : 3.7.7.final.0
python-bits : 64
OS : Windows
OS-release : 7
machine : AMD64
processor : Intel64 Family 6 Model 78 Stepping 3, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : Chinese (Simplified)_People's Republic of China.936
pandas : 1.0.3
numpy : 1.18.4
pytz : 2020.1
dateutil : 2.8.1
pip : 19.2.3
setuptools : 41.2.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : 3.1.1
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.5
pandas_gbq : None
pyarrow : None
pytables : None
pytest : None
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : None
tables : 3.6.1
tabulate : None
xarray : None
xlrd : 1.2.0
xlwt : None
xlsxwriter : None
numba