pandas fill N.A. for specific column
<p>I want to fill N.A. values in a specific column if a condition is met in another column to only replace this single class of N.A. values with an imputed / replacement value.</p>

<p>E.g.  I want to perform: <code>if column1 = 'value1' AND column2 = N.A fillna_in_column2 with value 'replacementvalue'</code></p>

<p>How do I achieve this in pandas?</p>

<p>Trying to do this via <code>dataframe[dataframe['firstColumn'] == 'value1'].fillna({'column2':'replacementValue'}</code> does not work as the length of the overall records is modified. So far I could not get an inplace modification to work.</p>

<pre><code>df.loc[(df['col1']==val1) &amp; (df['col2'].isnull()), 'col2'] = replacement_value
</code></pre>

python pandas fill na imputation