Home > Net >  Why is the error ("iAt based indexing can only have integer indexers") raised?
Why is the error ("iAt based indexing can only have integer indexers") raised?

Time:07-27

Why does the error occur when the value of of position is anything else than 1?

def sumarentradas(self, position):
        global dfEquipoLocal
        dfEquipoLocal.iat[position:2]  = 1
        dfEquipoLocal.iat[position:5]  = 1
        return dfEquipoLocal

I have checked the type of value of position and it remains as an integer, so why wont it allow me to increment the value?

CodePudding user response:

Pay attantion on the documentation with examples

Access a single value for a row/column pair by integer position.

Using this sintax [position:2] you are trying to get a slice instead of a single value from DataFrame. I guess [position, 2] meant to be here.

CodePudding user response:

from the docs of iat it explains that only single values are allowed

Similar to iloc, in that both provide integer-based lookups. Use iat if you only need to get or set a single value in a DataFrame or Series.

  • Related