Borrar filtros
Borrar filtros

Unable to outerjoin two tables, Error message of 'Left and right key variables have incompatible types'

4 visualizaciones (últimos 30 días)
Hi, it seems that no matter what I try, my left and right key variables will always be of incompatible types.
It's gotten so frustrating that I literally renamed Table A to have the exact same category names as Table B.
For example, each Table now has the same categories, One, Two, Three, Four, Five, and Six
But for some reason, matlab.mathworks.com keeps saying that 'Ordinal arrays must have the same categories, including their order' - which I believe I already made sure the tables were.
Dear community, what exactly am I doing wrong? Is MATLAB Online not compatible with joining tables?
My version is 2024a - Thanks.
  1 comentario
Jay Coin
Jay Coin el 19 de Mayo de 2024
Editada: Jay Coin el 19 de Mayo de 2024
The code I'm using is:
newTaxiALL = outerjoin(TableA,TableB,"Type","left","LeftKeys",["One","Two"],"RightKeys",["One","Two"],"MergeKeys",true);
But I get:

Iniciar sesión para comentar.

Respuestas (1)

Peter Perkins
Peter Perkins el 29 de Mayo de 2024
Jay, it's impossible to know what you are doing from what you've posted. outerjoin does work with ordinal key variables, so you will need to post more information.
x = [1;2;3];
g1 = categorical(["a";"b";"b"],Ordinal=true);
g2 = categorical(["c";"c";"d"],Ordinal=true);
t1 = table(x,g1,g2)
t1 = 3x3 table
x g1 g2 _ __ __ 1 a c 2 b c 3 b d
y = [4;5;6];
g1 = categorical(["a";"a";"b"],Ordinal=true);
g2 = categorical(["c";"d";"d"],Ordinal=true);
t2 = table(y,g1,g2)
t2 = 3x3 table
y g1 g2 _ __ __ 4 a c 5 a d 6 b d
outerjoin(t1,t2,"Type","left","LeftKeys",["g1","g2"],"RightKeys",["g1","g2"],"MergeKeys",true)
ans = 3x4 table
x g1 g2 y _ __ __ ___ 1 a c 4 2 b c NaN 3 b d 6

Categorías

Más información sobre Tables en Help Center y File Exchange.

Productos


Versión

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by