Git Product home page Git Product logo

Comments (2)

alexcwyu avatar alexcwyu commented on August 22, 2024

my current solution is extending the rc.DataFrame:

class DataFrame(rc.DataFrame):
    def __init__(self, series_list=None): # series_list is a list of rc.Series
        all_index = set()
        #data = {}
        columns = []

        for series in series_list:
            all_index |= set(series.index)
            columns.append(series.id)

        index = sorted(all_index)

        super(DataFrame, self).__init__(index=index, columns=columns)

        for i in index:
            data = {}
            for series in series_list:
                if i in series.index:
                    data[series.id] = series[i]
            self.set(indexes=i, values=data)

any better solution?

from raccoon.

rsheftel avatar rsheftel commented on August 22, 2024

I don't think there is an elegant way to do this right now. Using the native functionality if you know you only have one column then this works:

import raccoon as rc

df1 = rc.DataFrame(data={'close': [9,8,7,6]}, index=[0,2,4,6], sort=True)
df2 = rc.DataFrame(data={'open': [1,2,3,4,5,6,7]}, index=[0, 1, 2, 3, 4, 5, 6], sort=True)

df1.set(df2.index, df2.columns[0], df2.data[0])
df1.show()

  index    close    open
-------  -------  ------
      0        9       1
      1                2
      2        8       3
      3                4
      4        7       5
      5                6
      6        6       7

If you have more than one column you could just run a loop that repeats the above for each column

from raccoon.

Related Issues (10)

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.