Delete rows with "-" in categorial colum

17 ビュー (過去 30 日間)
Max1234
Max1234 2023 年 1 月 5 日
コメント済み: Voss 2023 年 1 月 6 日
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.

採用された回答

Voss
Voss 2023 年 1 月 5 日
編集済み: Voss 2023 年 1 月 5 日
t = table(["some";"strings";"in";"this";"column"],categorical(["Autumn";"Summer";"Winter";"-";"Winter"]))
t = 5×2 table
Var1 Var2 _________ ______ "some" Autumn "strings" Summer "in" Winter "this" - "column" Winter
idx = t{:,end} == "-";
t(idx,:) = []
t = 4×2 table
Var1 Var2 _________ ______ "some" Autumn "strings" Summer "in" Winter "column" Winter
counts = groupsummary(t,'Var2')
counts = 3×2 table
Var2 GroupCount ______ __________ Autumn 1 Summer 1 Winter 2
  2 件のコメント
Siddharth Bhutiya
Siddharth Bhutiya 2023 年 1 月 6 日
Using dot indexing would be faster since you dont really need the brace there.
t(t.Var2 == "-",:) = [];
Voss
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 ExchangeTables についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by