I am iterating through a dataframe and pulling out specific lines and then enriching those lines with some other elements. I have a dictionary that has the following definition mapping:
testdir = {0: 'zero', 40: 'forty', 60: 'sixty', 80: 'eighty'}
When i pull out a specific line from the original dataframe which looks like this
a b c x str
0 0 0 0 100.0 aaaa
i want the str cell to now be set to the string value of column c which is 0 so
output should be
a b c x str
0 0 0 0 100.0 zero
and then after meeting some other conditions a new line is pulled out from the original dataframe and the output should be
a b c x str
0 0 0 0 100.0 zero
3 4 30 60 100.0 sixty
i tried to use the map() method so something like'
df['str'][-1] = df['c'][-1].map(testdir)
but i'm erroring all over the place!