I have a pandas DataFrame with cities and a separate list with multipliers for each city. I want to update the TaxAmount in the first df with the corresponding multiplier for each city, from the list.
My current code functions and runs fine but it sets the multiplier to being the same for all cities instead of updating to a new multiplier. So basically all the city's tax rates are the same when they should be different. Any suggestions on how to get this to work?
import pandas as pd
df = pd.DataFrame({
'City': ['BELLEAIR BEACH', 'BELLEAIR BEACH', 'CLEARWATER', 'CLEARWATER'],
'TaxAnnualAmount': [5672, 4781, 2193.34, 2199.14]
})
flag = True
flag = (df['City'] == 'Belleair Bluffs')
if (flag.any() == True):
df.loc['TaxAnnualAmount'] = ((df['CurrentPrice'] / 1000) * 19.9818)
flag = True
flag = (df['City'] == 'Belleair')
if (flag.any() == True):
df.loc['TaxAnnualAmount'] = ((df['CurrentPrice'] / 1000) * 21.1318)
flag = True
flag = (df['City'] == 'Belleair Shore')
if (flag.any() == True):
df.loc['TaxAnnualAmount'] = ((df['CurrentPrice'] / 1000) * 14.4641)