joining one column from a table to another while matching all other columns
조회 수: 7 (최근 30일)
이전 댓글 표시
hello,
i have two tables a and b
a= Department Name ID
k Joe 12
l Laura 234
m Mike 45
b Tom 23
j Ash 55
b= Department Name ID Gender
l May 222 F
l Laura 234 F
m Gary 45 M
j Ash 55 M
a=table({['k','l','m','b','j'],['Joe','Laura','Mike','Tom','Ash'],[12,234,45,23,55]},'VariableNames',{'Department','name','ID'});
b=table({['l','l','m','j'],['May','Laura','Gary','Ash'],[222,234,45,55],['F','F','M','M']},'VariableNames',{'Department','name','ID','Gender'});
I want to join b on a when all Departmen, ID and Name match with the resultant only showing these three columns once and adding a fourth coulum that has Gender as follows
ans== Department Name ID Gender
k Joe 12 Nan
l Laura 234 F
m Mike 45 Nan
b Tom 23 Nan
j Ash 55 M
l May 222 Nan
m Gary 45 Nan
댓글 수: 0
채택된 답변
the cyclist
2020년 6월 21일
(Your code won't produce the tables a and b.)
a = table({'k','l','m','b','j'}',{'Joe','Laura','Mike','Tom','Ash'}',[12,234,45,23,55]', ...
'VariableNames',{'Department','name','ID'});
b = table({'l','l','m','j'}',{'May','Laura','Gary','Ash'}',[222,234,45,55]',{'F','F','M','M'}', ...
'VariableNames',{'Department','name','ID','Gender'});
outerjoin(a,b,'MergeKeys',true)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!