title: Conditional Row shift in Pandas
body: <p>I'm attempting to shift a row based on whether or not another column is not null. There's inconsistent spacing in the Description column so I can't do a .shift()</p>
  <p>Here's the original data</p>
  <pre><code>Permit Number    A      Description
  1234            NaN    NaN
  NaN             NaN    NaN
  NaN             NaN    foo
  3456            NaN    NaN
  NaN             NaN    bar
  </code></pre>
  <p>And this is what I want my result to be</p>
  <pre><code>Permit Number    A      Description
  1234            NaN    foo
  NaN             NaN    NaN
  NaN             NaN    NaN
  3456            NaN    bar
  NaN             NaN    NaN
  </code></pre>
  <p>Here's the code that I used from <a href="https://stackoverflow.com/questions/45381840/align-data-in-one-column-with-another-row-based-on-the-last-time-some-condition">Align data in one column with another row, based on the last time some condition was true</a></p>
  <pre><code>mask = df['Description'].notnull()
  fmask = (df['Permit Number'].notnull() &amp; df['Description'].isnull())
  df.assign(Description=df.groupby(mask[::-1].cumsum())['Description'].transform(lambda x: x.iloc[-1]).where(fmask))
  </code></pre>
  <p>However when I run it, no errors and no changes in the dataframe.</p>