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

3 ビュー (過去 30 日間)
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 件のコメント
Jay Coin
Jay Coin 2024 年 5 月 19 日
編集済み: Jay Coin 2024 年 5 月 19 日
The code I'm using is:
newTaxiALL = outerjoin(TableA,TableB,"Type","left","LeftKeys",["One","Two"],"RightKeys",["One","Two"],"MergeKeys",true);
But I get:

サインインしてコメントする。

回答 (1 件)

Peter Perkins
Peter Perkins 2024 年 5 月 29 日
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

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by