필터 지우기
필터 지우기

How to find missing values in a table and delete the row along with all other associated rows

조회 수: 14 (최근 30일)
I have a imported data into a table named V in MATLAB. The first column contains dates in the form 01/01/1987 00:00, everyday for 31 years. The other columns are variables.
Some of the variables data is missing in column 3 (NaN in the cells) and I would like to delete all rows with missing data but also then check what year that row was and delete all other rows of the same year.
There are too many rows to do this by inspection so I cannot use rmmissing(V) as I won't be able to check what was deleted and then delete all other rows of the same year. By the same reason I also cannot use:
V(V.(3) == 0, :) = [];
Any help would be much appreciated.

채택된 답변

Cris LaPierre
Cris LaPierre 2021년 7월 2일
It seems a solution will need to be highly customized to your particular data set. Since you haven't shared your data, here's my best guess.
% Find rows missing data in var3
ind = ismissing(V.(3));
% Extract the year corresponding to missing data
yr = unique(year(V{ind,1}));
% Find rows of table from same years as missing data
rm = ismember(year(V.(1)),yr);
% delete
V(rm,:) = [];

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by