Pandas: how to increment a column's cell value based on a list of ids
<p>I have a list of ids that correspond to the row of a data frame. From that list of ids, I want to increment a value of another column that intersects with that id's row.</p>

<p>What I was thinking was something like this:</p>

<pre><code>ids = [1,2,3,4]

for id in ids:
    my_df.loc[my_df['id']] == id]['other_column'] += 1
</code></pre>

<p>But this doesn't work. How can I mutate the original df, <code>my_df</code>?</p>

<p>the ids are unique, correct?  If so, you can directly place the <code>id</code> into the <code>df</code>:</p>

<pre><code>ids = [1,2,3,4]

for id in ids:
    df.loc[id,'column_name'] = id+1
</code></pre>

python pandas dataframe