Delete rows with "-" in categorial colum
조회 수: 3 (최근 30일)
이전 댓글 표시
Hey guys,
I have two questions, maybe someone can help me. Thanks in advance.
I have a table with four columns: String, String, Datum, Categorial. I would like to remove all rows where there is a "-" in the categorial column.
There are only three words in the column: "Autumn", "Summer" and "Winter". I would like to display how many cells are filled with each word.
댓글 수: 0
채택된 답변
Voss
2023년 1월 5일
편집: Voss
2023년 1월 5일
t = table(["some";"strings";"in";"this";"column"],categorical(["Autumn";"Summer";"Winter";"-";"Winter"]))
idx = t{:,end} == "-";
t(idx,:) = []
counts = groupsummary(t,'Var2')
댓글 수: 2
Siddharth Bhutiya
2023년 1월 6일
Using dot indexing would be faster since you dont really need the brace there.
t(t.Var2 == "-",:) = [];
Voss
2023년 1월 6일
Thanks! I used brace indexing in that case so that the OP could run the code without having to know they need to change the Var2 variable name to whatever their table's categorical variable name is.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Preprocessing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!