title: How to replace nan / fillna per group in a pandas dataframe?
body: <p>I have the following data:</p>
  <pre><code>               type           group
  0           Drought  Climatological
  1               nan  Climatological
  2         Explosion   Technological
  3   Ground movement     Geophysical
  4               nan     Geophysical
  5          Ash fall     Geophysical
  6          Rockfall     Geophysical
  7          Ash fall     Geophysical
  8               nan   Technological
  9         Explosion   Technological
  10              nan  Meteorological
  </code></pre>
  <pre><code>data_pd = pd.DataFrame({'type':['Drought','nan','Explosion','Ground movement','nan','Ash fall','Rockfall','Ash fall','nan','Explosion','nan'],  
                          'group':['Climatological','Climatological','Technological','Geophysical','Geophysical',  
                          'Geophysical','Geophysical','Geophysical','Technological','Technological','Meteorological']})
  </code></pre>
  <p>How can I replace the <code>'nan'</code> depending on the group?</p>
  <h5>Below is my current approach:</h5>
  <p>I want to replace <code>nan</code> strings that match with specific strings from the next row in another column by some alternative string.</p>
  <p>Here's a sample of data from my dataset where it seizes to work this was an output from <code>pd.to_dict()</code> I wanted to keep it as it is to replicate my issue.:</p>
  <pre><code>for ty, go in zip(data_pd['type'].values, data_pd['group'].values):
      if ty == 'nan' and go == 'Climatological':
          #ty = ['Drought']
          print(ty) #prints nothing as it did not work
  
  </code></pre>