1. 背景
pandas在数据分析应用中使用频率非常高的python 库,在数据分析的过程中,读写文件是非常基础的操作,它关系到整个数据分析的性能表现。下面就用程序验证pandas 读写常见几种文件的性能表现。
2. 代码验证
import pandas as pd
import time
import numpy as np
def write_data(df):
store = pd.HDFStore('D:\\test\\store.h5')
start = time.time()
store['df'] = df
store.close()
print(f'HDF5存储用时{
time.time() - start}秒')
start = time.time()
df.to_csv('d:\\test\\df.csv', index=False)
print(f'csv存储

文章通过Python的pandas库测试了HDF5、CSV、pickle、parquet和feather等文件格式的读写性能,发现HDF5、pickle和parquet在处理大数据时具有较好的速度和空间占用率。
最低0.47元/天 解锁文章
798





