Innerjoin in Octave

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Innerjoin in Octave

zutboy
Hello,

I'm not sure if this is the right way to seek help on this topic.

I want to innerjoin two tables in Octave.
In Matlab I know it's fairly easy to do this:
A = table([10;22;2;3;7],[5;4;9;6;1],[10;3;8;8;4])
B = table([6;1;1;6;8],[2;3;4;5;6])
[C,ia,ib] = innerjoin(A,B,'LeftKeys',1,'RightKeys',2)

How does one do this in Octave?
I am new to loops, so if you could help me it would be much appreciated.

Kind regards,
Scott



Reply | Threaded
Open this post in threaded view
|

Re: Innerjoin in Octave

nrjank


On Wed, Apr 24, 2019, 4:12 PM zutboy <[hidden email]> wrote:
Hello,

I'm not sure if this is the right way to seek help on this topic.

I want to innerjoin two tables in Octave.
In Matlab I know it's fairly easy to do this:
A = table([10;22;2;3;7],[5;4;9;6;1],[10;3;8;8;4])
B = table([6;1;1;6;8],[2;3;4;5;6])
[C,ia,ib] = innerjoin(A,B,'LeftKeys',1,'RightKeys',2)

How does one do this in Octave?
I am new to loops, so if you could help me it would be much appreciated.


Just to confirm, innerjoin was added to MATLAB in 2013, and I believe its still in the missing functions list. I don't know if the table class has been implemented at all yet. Doing this in octave may be possible, but I'm not sure what the alternative approach would be since I'm not familiar with what inner join is trying to do..


Reply | Threaded
Open this post in threaded view
|

Re: Innerjoin in Octave

apjanke-floss


On 4/24/19 10:43 PM, Nicholas Jankowski wrote:

>
>
> On Wed, Apr 24, 2019, 4:12 PM zutboy <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hello,
>
>     I'm not sure if this is the right way to seek help on this topic.
>
>     I want to innerjoin two tables in Octave.
>     In Matlab I know it's fairly easy to do this:
>     A = table([10;22;2;3;7],[5;4;9;6;1],[10;3;8;8;4])
>     B = table([6;1;1;6;8],[2;3;4;5;6])
>     [C,ia,ib] = innerjoin(A,B,'LeftKeys',1,'RightKeys',2)
>
>     How does one do this in Octave?
>     I am new to loops, so if you could help me it would be much appreciated.
>
>
> Just to confirm, innerjoin was added to MATLAB in 2013, and I believe
> its still in the missing functions list. I don't know if the table class
> has been implemented at all yet. Doing this in octave may be possible,
> but I'm not sure what the alternative approach would be since I'm not
> familiar with what inner join is trying to do..
>
>

The table class has not been implemented in core Octave.

I'm working on a package to provide it, though:
https://github.com/apjanke/octave-table.

octave-table is a work in progress and it's definitely not ready for
production use, but enough of the basic functionality is there that you
can use it to do an innerjoin:

>> A = table([10;22;2;3;7],[5;4;9;6;1],[10;3;8;8;4])
A =
table: 5 rows x 3 variables
  VariableNames: Var1, Var2, Var3
>> B = table([6;1;1;6;8],[2;3;4;5;6])
B =
table: 5 rows x 2 variables
  VariableNames: Var1, Var2
>> [C,ia,ib] = innerjoin(A,B,'LeftKeys',1,'RightKeys',2)
C =
table: 2 rows x 4 variables
  VariableNames: Var1, Var2, Var3, Var1_B
ia =
   3   1
   4   2

ib =
   1
   2

>> prettyprint(C)
-------------------------------
| Var1 | Var2 | Var3 | Var1_B |
-------------------------------
| 2    | 9    | 8    | 6      |
| 3    | 6    | 8    | 1      |
-------------------------------
>>

You might find it useful. Any feedback is appreciated.

There's also the Octave Forge Dataframe package -
https://wiki.octave.org/Dataframe_package - but I don't know if it
supports joins.

Cheers,
Andrew