0
I have a problem in my for, where all the results are coming out as the same value within Dataframe, but I can’t understand the error, someone could help me
import pandas as pd
BRICS=pd.DataFrame({'País':["Brasil","Russia","India","China","Africa do Sul"],'Capital':['Brasilia','Moscou','Nova Deli','Beijing','Pretoria'],'Area':[8.516,17.100,3.286,9.597,1.221],'População':[200.40,143.50,1252.00,1357.00,52.98]})
print(BRICS,'\n')
for i in range(len(BRICS)):
BRICS=BRICS.assign(Densidade=BRICS['População'].values[i]/BRICS['Area'].values[i])
print(BRICS)
tried to make
BRICS['Densidade'] = BRICS['População'] / BRICS['Area']
orBRICS.assign(Densidade=BRICS['População']/BRICS['Area'])
without thefor
?– Icaro Martins