1

I know that by Daru::DataFrame#concat one can concatenate dataframes, appending the argument df to the bottom of the caller df.

Now I want to achieve what is df.concat(other, axis=1) in Pandas. In other words, given I have two dataframes where the index are the same, append one df to the right of the other df, resulting df having same index but the concatenated vectors.

Is this possible by some method? Or do I need to iterate and add each columns in for loop?

Yuki Inoue
  • 3,569
  • 5
  • 34
  • 53

2 Answers2

1

Is this what you are looking for possibly?

data_frame = data_frame.join(jobs_data_frame, how: :left, on: [:user_id])

janpeterka
  • 568
  • 4
  • 17
0

You can use add_vector method.

For eg:

2.6.3 :001 > require 'daru'

2.6.3 :007 > df = Daru::DataFrame.new([[00,01,02], [10,11,12],[20,21,22]], order: ["a", "b", "c"])
 => #<Daru::DataFrame(3x3)>
       a   b   c
   0   0  10  20
   1   1  11  21
   2   2  12  22
2.6.3 :008 > df.add_vector("d", [30, 31, 32])
 => [30, 31, 32]
2.6.3 :009 > df
 => #<Daru::DataFrame(3x4)>
       a   b   c   d
   0   0  10  20  30
   1   1  11  21  31
   2   2  12  22  32

Although you'll have to add each vector separately.

Nikhil Wagh
  • 1,376
  • 1
  • 24
  • 44