Is this what are you looking for?
populationAM = pops.loc[pops.Name == 'Amsterdam', 'populationEst'].iloc[0]
populationNL = pops.loc[pops.Name == 'Netherlands', 'populationEst'].iloc[0]
frac = populationAM * 100 / populationNL
The value of frac
here is 5.013659275539944, while populationAM
and populationNL
are the integers corresponding to the respective populations (as you can see, the type of these variables is not a problem to compute the correct value of frac
). In your code, the issue is that populationAM
and populationNL
are pandas Series, instead of integers; iloc[0]
retrieves the value in the first position of the series.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…