Code Monkey home page Code Monkey logo

dataframe's Introduction

Build status Build Status
GitHub GitHub tag (latest by date)
C++17 Codacy Badge Binder

drawing

This is a C++ analytical library that provides interface and functionality similar to packages/libraries in Python and R. For example, you could compare this to Pandas or R data.frame.
You could slice the data in many different ways. You could join, merge, group-by the data. You could run various statistical, summarization, financial, and ML algorithms on the data. You could add your custom algorithms easily. You could multi-column sort, custom pick and delete the data. And more …
DataFrame also includes a large collection of analytical algorithms in form of visitors -- see documentation. These are from basic stats such as Mean, Std Deviation, Return, … to more involved analysis such as Affinity Propagation, Polynomial Fit, Hurst Exponent … including a good collection of trading indicators -- See documentation for a complete list with code samples, and how you can add your custom algorithms.

I have followed a few principles in this library:

  1. Support any type either built-in or user defined without needing new code
  2. Never chase pointers ala linked lists, std::any, pointer to base, ..., including virtual functions
  3. Have all column data in continuous memory space. Also, be mindful of cache-line aliasing misses between multiple columns
  4. Never use more space than you need ala unions, std::variant, ...
  5. Avoid copying data as much as possible
  6. Use multi-threading but only when it makes sense
  7. Do not attempt to protect the user against garbage in, garbage out

DateTime
DateTime class included in this library is a very cool and handy object to manipulate date/time with nanosecond precision and multi timezone capability.


Performance

There is a test program dataframe_performance that should give you a sense of how this library performs. As a comparison, there is also a Pandas pandas_performance script that does exactly the same thing.
dataframe_performance.cc uses DataFrame async interface and is compiled with gcc compiler with -O3 flag. pandas_performance.py is ran with Pandas 1.2 and Python 3.7. I ran both on my mac-book, doing the following:
drawing

  1. Generate ~1.6 billion timestamps (second resolution) and load them into the DataFrame/Pandas as index.
  2. Generate ~1.6 billion random numbers for 3 columns with normal, log normal, and exponential distributions and load them into the DataFrame/Pandas.
  3. Calculate the mean of each of the 3 columns.

Result:

MacBook> time python test/pandas_performance.py
All memory allocations are done. Calculating means ...
-4.318030613360519e-05, 1.6486147626420655, 1.0000042573786951

real  17m18.916s
user  4m47.113s
sys   5m31.901s


MacBook> time bin/Linux.GCC64/dataframe_performance
All memory allocations are done. Calculating means ...
1, 1.64879, 0.999994

real  4m15.786s
user  2m30.841s
sys   1m36.944s

The Interesting Part:

  1. Pandas script, I believe, is entirely implemented in Numpy which is in C.
  2. In case of Pandas, allocating memory + random number generation takes almost the same amount of time as calculating means.
  3. In case of DataFrame ~90% of the time is spent in allocating memory + random number generation.
  4. You load data once, but calculate statistics many times. So DataFrame, in general, is about ~21x faster than parts of Pandas that are implemented in Numpy. I leave parts of Pandas that are purely in Python to imagination.
  5. Pandas process image at its peak is ~105GB. C++ DataFrame process image at its peak is ~56GB.

DataFrame Test File
DataFrame Test File 2
Heterogeneous Vectors Test File
Date/Time Test File


Contributions
License


Installing using CMake

mkdir [Debug | Release]
cd [Debug | Release]
cmake -DCMAKE_BUILD_TYPE=[Debug | Release] ..
make
make install

cd [Debug | Release]
make uninstall

Package managers

If you are using Conan to manage your dependencies, add dataframe/x.y.z@ to your requires, where x.y.z is the release version you want to use. Conan will acquire DataFrame, build it from source in your computer, and provide CMake integration support for your projects. See the Conan docs for more information.
Sample conanfile.txt:

[requires]
dataframe/1.17.0@

[generators]
cmake

dataframe's People

Contributors

hosseinmoein avatar justinjk007 avatar bplaa-yai avatar yssource avatar alexandre-p-j avatar thekvs avatar schorrm avatar spotys avatar theirix avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.