pandas filter and change the value of a column pandas code example Example: pandas filter and change value df.loc[df['dollars_spent'] > 0, 'purchase'] = 1