Git Product home page Git Product logo

raccoon's Introduction

raccoon

Python DataFrame with fast insert and appends

Documentation Status

Documentation

http://raccoon.readthedocs.io/en/latest/

Source location

Hosted on GitHub: https://github.com/rsheftel/raccoon

Overview

Raccoon is a lightweight DataFrame and Series implementation inspired by the phenomenal Pandas package for the one use case where Pandas is known to be sub-optimal: DataFrames and Series that grow in size by adding rows frequently in the code. Additionally Raccoon DataFrames and Series can be parametrized to be sorted so that additions to the DataFrame keep the index in sorted order to speed inserts and retrievals.

A simple speed comparison of Raccoon vs Pandas for typical functionality is located in the documentation.

Inspiration

Pandas DataFrames and Series are excellent multi-purpose data structures for data management and analysis. One of the use cases I had was to use DataFrames as a type of in-memory database table. The issue was that this required lots of growing the number rows of the DataFrame, something that is known to be slow in Pandas. The reason it is slow in Pandas is that the underlying data structure is numpy which does a complete copy of the data when the size of the array grows.

Functionality

Raccoon implements what is needed to use the DataFrame as an in memory store of index and column data structure supporting simple and tuple indexes to mimic the hierarchical indexes of Pandas. The methods included are primarily about setting values of the data frame, growing and appending the data frame and getting values from the data frame. The raccoon DataFrame is not intended for math operations like pandas and only limited basic math methods are included.

Underlying Data Structure

Raccoon uses the standard built in lists as its default underlying data structure. There is an option on object construction to use any other drop-in replacement for lists. For example the fast blist package http://stutzbachenterprises.com/blist/ could be used as a list replacement for the underlying data structure.

Why Raccoon?

According to wikipedia some scientists believe the panda is related to the raccoon

Contributing

Contribution in the form of pull requests are welcome. Use pytest to run the test suite. Be sure any new additions come with accompanying tests.

Future

This package serves the needs it was originally created for. Any future additions by myself will be driven by my own needs, but it is completely open source so I encourage anyone to add on and expand.

My hope is that one day Pandas solves the speed problem with growing DataFrames and this package becomes obsolete.

Python Version

Raccoon requires Python 3.4 or greater. Python 2.7 support was eliminated as of version 3.0. If you need to use raccoon with Python 2.7 use any version less than 3.0

Helper scripts

There is helper function to generate these docs from the source code. On windows cd into the docs directory and execute make_docs.bat from the command line. To run the test coverage report run the coverage.sh script.

raccoon's People

Contributors

bearsh avatar nagesh4193 avatar rsheftel avatar tonycpsu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

raccoon's Issues

Python 2 support?

Hi there, this is a neat project that might help me with something I'm working on that doesn't lend itself well to how Pandas works. Problem is I do most of my work in Python 2.7. It didn't take long for me to make your code 2.x compatible -- mostly just replaced some of the list.copy()s with list[:]s and removed the type hints. If you're interested I can send a PR -- if not I'll just keep using what I have.

support creating DataFrame with Series with different index

say I have 2 timeseries with different index

TimeSeries1

timestamp close
0 0.582778
2 0.682441
4 0.0365585
6 0.549261
8 0.0575284

TimeSeries2

timestamp open
0 0.525396
1 0.380595
2 0.399267
3 0.309334
4 0.339246
5 0.91433
6 0.30177
7 0.814401
8 0.722506
9 0.0100632

does Raccoon support the creation of Dataframe from them?
it doesn't look like it is support this but let me know if I am wrong

Question: does raccoon use the e.g. the bisect functions from the dropins?

looking at get_slice():

start_location = bisect_left(self._index, start_index) if start_index is not None else None

there bisect_left from bisect is used. if blist is used as dropin it provides its own bisect_left implementation. but as far as I understand the code, this implementation is not used.

would it makes sense to query the list first if it provides a bisect function?

Custom sort keys / ordering

I was wondering if you had any plans to implement custom sorting of rows with the sort_columns function. Things like being able to pass in a custom key or comparator function, sort in reverse, etc. I don't see any way to do this currently.

Start

Begin the project

Bug in set_column index check

In set_column, I believe the following check is erroneous:

    if len(index) == (index.count(True) + index.count(False)):  # boolean list

This works in most cases, but in the rare case where the index consists only of combinations of 0 and 1, Python's quirky type system causes the code above to assume that what is being passed in is a boolean list when it's actually numeric IDs. 1==True and 0==False are helpful in many cases, but not this one.

Something like:

    if all([isinstance(i, bool) for i in index]):

Would probably do the right thing.

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.