Delete rows with "-" in categorial colum
4 次查看(过去 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!