timetable.rmmissing
timetable: ttB = rmmissing (ttA)
timetable: ttB = rmmissing (ttA, Name, Value)
timetable: [ttB, TF] = rmmissing (…)
Remove the incomplete rows of a timetable.
ttB = rmmissing (ttA) removes every row holding a
missing value.
A row whose row time is missing is removed whatever its
variables hold, and whatever 'DataVariables' or
'MinNumMissing' say: a row that cannot be placed in time is
not a row a timetable can keep. That is a precondition rather than a
report of missingness, which is why ismissing does not mark
such a row and anymissing does not count it.
'DataVariables' names the variables to judge a row by, and
'MinNumMissing' how many missing values a row must hold before
it goes. Neither reaches the row times.
[ttB, TF] = rmmissing (…) also returns a
logical column marking the rows that were removed, the ones dropped
for their row times included.
The time step is read afresh from the rows that survive.
See also: ismissing, standardizeMissing, timetable
Source Code: timetable
rmmissing drops the rows holding a missing value, and reports which ones went.
t0 = datetime (2024, 1, 1); Depth = [12; 45; NaN; 8]; TT = timetable (Depth, 'RowTimes', t0 + hours (0:3)')
TT =
4x1 timetable
Time Depth
____________________ _____
01-Jan-2024 00:00:00 12
01-Jan-2024 01:00:00 45
01-Jan-2024 02:00:00 NaN
01-Jan-2024 03:00:00 8
[R, TF] = rmmissing (TT); R
R =
3x1 timetable
Time Depth
____________________ _____
01-Jan-2024 00:00:00 12
01-Jan-2024 01:00:00 45
01-Jan-2024 03:00:00 8
TF
TF = 0 0 1 0
A row whose time is missing goes whatever its data holds. That is a precondition rather than a report of missingness: ismissing does not mark such a row and anymissing does not count it, yet rmmissing cannot keep a row it has no way to place in time.
t0 = datetime (2024, 1, 1);
TT = timetable ([12; 45; 23], 'RowTimes', [t0; NaT; t0 + hours(2)], ...
'VariableNames', {'Depth'});
anymissing (TT)
ans = 0
rmmissing (TT)
ans =
2x1 timetable
Time Depth
____________________ _____
01-Jan-2024 00:00:00 12
01-Jan-2024 02:00:00 23
Neither 'DataVariables' nor 'MinNumMissing' reaches the row times, so neither can spare that row.
rmmissing (TT, 'MinNumMissing', 2)
ans =
2x1 timetable
Time Depth
____________________ _____
01-Jan-2024 00:00:00 12
01-Jan-2024 02:00:00 23