DeleteMissing

DeleteMissing[list]
drops elements with head Missing from a list.

DeleteMissing[assoc]
drops elements whose values have head Missing from the association assoc.

DeleteMissing[expr,n]
applies DeleteMissing to any lists or associations that occur within the first n levels of expr.

DeleteMissing[expr,n,d]
considers an element at level n to be missing if Missing occurs within the first d levels of the element.

DetailsDetails

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Delete Missing elements in a list:

In[1]:=
Click for copyable input
Out[1]=

Delete Missing values from an association:

In[2]:=
Click for copyable input
Out[2]=

Delete Missing elements up to level 2:

In[1]:=
Click for copyable input
Out[1]=

Without an explicit level, only the top level is processed:

In[2]:=
Click for copyable input
Out[2]=

Delete elements at level 1 if they themselves contain Missing:

In[1]:=
Click for copyable input
Out[1]=

Without a third argument, elements that contain Missing are not removed:

In[2]:=
Click for copyable input
Out[2]=

An element will not be removed unless the specified depth is greater than or equal to the depth of the Missing:

In[3]:=
Click for copyable input
Out[3]=
In[4]:=
Click for copyable input
Out[4]=
Introduced in 2014
(10.0)