Removing entire column if any of the value in that column contains a NaN
1 次查看(过去 30 天)
显示 更早的评论
I am trying to clean up my dataset. Therfore I want to remove any columns that contain any Nan values.
The dataset is of form table. I have tried a few approaches but did not succeed
0 个评论
采纳的回答
Voss
2022-4-4
% make a table with some NaNs:
A = magic(5);
A([7 15]) = NaN;
t = array2table(A)
% remove columns/table-variables with any NaNs:
t(:,any(isnan(t{:,:}),1)) = []
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 NaNs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!