title: Convert pandas dataframe to dict to JSON, unflatten nested subkeys, drop None/NaN keys
body: <p>Can the following be done in Pandas in one go, in more Pythonic code than below? </p>
  
  <p>I have a row from a pandas-dataframe:</p>
  
  <ul>
  <li>some values may be NaNs or empty strings or similar</li>
  <li>I'd like to map this information to a dict (which is then converted to JSON and passed on to another application)</li>
  <li>However, NaNs should not be included in the dict. (By default they are passed as <code>None</code>)</li>
  <li>Dict subkeys <code>'c.x', 'c.y', 'c.z'</code> should be unflattened, i.e. converted to a subdict <code>c</code> with keys <code>x, y, z</code>. Again, NaN keys in each row should be dropped.</li>
  </ul>
  
  <p><strong>Sample input:</strong> I iterate over rows in a dataframe with <code>row = next(df.iterrows())</code>, where a sample row would look like:</p>
  
  <pre><code>a        3
  b      NaN
  c.x      4
  c.y      5
  c.z    NaN
  </code></pre>
  
  <p><strong>Desired output</strong> </p>
  
  <pre><code>{"A": 3,
  "C": {"X": 4, "Y": 5}}
  </code></pre>
  
  <p>The most natural way (to me) to do that would like something like this:</p>
  
  <pre><code>outdict={"A": row['a'] if not pandas.isna(row['a']) else None,
      "B": row['b'] if not pandas.isna(row['b']) else None,
      "C": {"X": row['c.x'] if not pandas.isna(row['c.x']) else None,
          "Y": row['c.y'] if not pandas.isna(row['c.y']) else None,
          "Z": row['c.z'] if not pandas.isna(row['c.z']) else None
  }}
  </code></pre>
  
  <p>However, this still assigns <code>None</code> to the slots that I'd like to remain empty (the receiving application is difficult in handlings <code>nulls</code>).</p>
  
  <p>One workaround would be using this code and subsequently removing all None values in a second pass, or I could use <code>outdict.update</code> for each value (and not update if the value is <code>NaN</code>). But both solutions seems not very efficient to me.</p>