I have this data frame where I sliced columns from the original data frame:
Type 1 Attack
Grass 62
Grass 82
Dragon 100
Fire 52
Rock 100
I want to create each Pokemon’s adjusted attack attribute against grass Pokemon based on ‘Type 1’ where;
- the attack attribute is doubled if grass Pokemon are bad against that type
- halved if they are good against that type
- else remains the same.
I have looping through the data:
grass_attack = []
for value in df_["Type 1"]:
if value ==["Type 1 == Fire"] or value==["Type 1 == Flying"] or value==["Type 1 == Poison"] or value==["Type 1 == Bug"] or value==["Type1== Steel"] or value ==["Type 1 == Grass"] or value ==["Type 1 == Dragon"]:
result.append(df_["Attack"]/2)
elif value==["Type 1==Ground"] or value==["Type1== Ground"] or value==["Type 1 == Water"]:
grass_attack.append(df_["Attack"]*2)
else:
grass_attack.append(df_["Attack"])
df_["grass_attack"] = grass_attack
print(df_)
but I got some crazy results after this. How can I efficiently loop through a data frame's column in order to adjust another column?
or is there another way to do this?
value ==["Type 1 == Fire"]this has no sense at all, how a value of a column (a string) would be equal to a list of one string, that contains some equality