ml-finance-python

python scripts for finance machine learning

git clone https://9o.is/git/ml-finance-python.git

README.md

(1577B)


      1 ## Efficient data storage with pandas
      2 
      3 The notebook [storage_benchmark](storage_benchmark.ipynb) compares the main storage formats for efficiency and performance. 
      4 
      5 In particular, it compares:
      6 - CSV: Comma-separated, standard flat text file format.
      7 - HDF5: Hierarchical data format, developed initially at the National Center for Supercomputing, is a fast and scalable storage format for numerical data, available in pandas using the PyTables library.
      8 - Parquet: A binary, columnar storage format, part of the Apache Hadoop ecosystem, that provides efficient data compression and encoding and has been developed by Cloudera and Twitter. It is available for pandas through the pyarrow library, led by Wes McKinney, the original author of pandas.
      9 
     10 
     11 It uses a test `DataFrame` that can be configured to contain numerical or text data, or both. For the HDF5 library, we test both the fixed and table format. The table format allows for queries and can be appended to. 
     12 
     13 ### Test Results
     14 
     15 In short, the results are: 
     16 - For purely numerical data, the HDF5 format performs best, and the table format also shares with CSV the smallest memory footprint at 1.6 GB. The fixed format uses twice as much space, and the parquet format uses 2 GB.
     17 - For a mix of numerical and text data, parquet is significantly faster, and HDF5 uses its advantage on reading relative to CSV.
     18 
     19 The notebook illustrates how to configure, test, and collect the timing using the `%%timeit` cell magic. At the same time demonstrates the usage of the related pandas commands required to use these storage formats.