Pandas - add value at specific iloc into new dataframe column : <p>I have a large dataframe containing lots of columns.</p>

<p>For each row/index in the dataframe I do some operations, read in some ancilliary ata, etc and get a new value. Is there a way to add that new value into a new column at the correct row/index?</p>

<p>I can use .assign to add a new column but as I'm looping over the rows and only generating the data to add for one value at a time (generating it is quite involved). When it's generated I'd like to immediately add it to the dataframe rather than waiting until I've generated the entire series.</p>

<p>This doesn't work and gives a key error:</p>

<pre><code>df['new_column_name'].iloc[this_row]=value
</code></pre>

<p>Do I need to initialise the column first or something?</p>
