What is the best way to make iterrows with a subset of a DataFrame?
Take the following simple example:
import pandas as pd df = pd.DataFrame({ 'Product': list('AAAABBAA'), 'Quantity': [5,2,5,10,1,5,2,3], 'Start' : [ DT.datetime(2013,1,1,9,0), DT.datetime(2013,1,1,8,5), DT.datetime(2013,2,5,14,0), DT.datetime(2013,2,5,16,0), DT.datetime(2013,2,8,20,0), DT.datetime(2013,2,8,16,50), DT.datetime(2013,2,8,7,0), DT.datetime(2013,7,4,8,0)]}) df = df.set_index(['Start'])
Now, I would like to change a subset of this DataFrame using the itterrows function, for example:
for i, row_i in df[df.Product == 'A'].iterrows(): row_i['Product'] = 'A1'
However, the changes are not saved.
Is it possible (other than manual search using the index "i") to make permanent changes to the original Dataframe?