I ran a test which tested 10 ways to write and 10 ways to read a DataFrame. I found the test here (I made some ajustements and added Parquet to the list) The best ways were :
df.to_feather('test.feather') :
39.34544535900204s
table=pyarrow.Table.from_pandas(df)
pq.write_table(table, "test_parquet_write_snappy_dict.parquet",
use_dictionary=True, version='2.0', compression='snappy') :
40.6873751259991s
table=pyarrow.Table.from_pandas(df, nthreads=4)
pq.write_table(table, "test_parquet_write_snappy_dict.parquet",
use_dictionary=True, version='2.0', compression='snappy') :
41.051620177000586s
for the writing
and
pd.read_hdf('test_fixed.hdf', 'test') :
1.5275615360005759
pd.read_feather('test.feather') :
20.635139821002667
pd.read_pickle('test.pkl') :
37.21131302599679
for the reading.
Here's the DataFrame :
sz = 50000000
df = pd.DataFrame({'A': randn(sz), 'B': randn(sz), 'C': randn(sz), 'D': randn(sz)})
I have two questions. How read_hdf is 20 times fastest than read_feather while to_hdf isn't even in the first three of the write tests ?
And second one, 40 seconds is still too slow for my needs. Would there be a way to improve that speed ? Either by using different parameters with to_feather or write_table or using a function/module I doesn't know about ?
I'm not asking for someone to look up for me, I can do this myself and I don't want to waste anybody's time. I'm looking for someone who already know this problem and could lead me to the fastest way he knows.