title: Remove dictionary if we have value is nan/None/NaN/null for key using python
body: <p>I want to remove dictionary if value is nan/None/NaN/null for key . If nan is the only value in case of phone_type work then remove full dictionary itself.</p>
  <p><strong>Input Data</strong></p>
  <pre><code>dic = ['Customer_Number': 12345,'Phone_Number': [{'Phone_Type': 'Mobile', 'Phone': [1217]}, {'Phone_Type': 'work', 'Phone': [nan]}]]
  </code></pre>
  <p><strong>Expected Output Data</strong></p>
  <pre><code>dic = ['Customer_Number': 12345,'Phone_Number': [{'Phone_Type': 'Mobile', 'Phone': [1217]}]]
  </code></pre>
  <p><strong>code tried</strong></p>
  <pre><code>#define which elements you want to remove:
  to_be_deleted = [[], {}, &quot;&quot;, None, &quot;nan&quot;,nan, &quot;NaN&quot;, NaN]
  
  
  def remove_empty_elements(jsonData):
      if isinstance(jsonData, list):
          print(&quot;jsonDAta:&quot;, jsonData)
          jsonData = [remove_empty_elements(elem) for elem in jsonData
                      if remove_empty_elements(elem) not in to_be_deleted]
  
      elif isinstance(jsonData, dict):
          jsonData = {key: remove_empty_elements(value) for key, value in jsonData.items()
                      if remove_empty_elements(value) not in to_be_deleted}
  
  
          if len(jsonData) == 1:
              return None
  
      return jsonData
  
  res = remove_empty_elements(dic)
  </code></pre>