This is my code to check if a certain cell in my Dataframe is empty. Bfore there is a for loop to iterate over the rows. the counter is i
if change.isna(change.iloc[i,3]):
continue
Can't figure out why I receive the
**TypeError**: isna() takes 1 positional argument but 2 were given
Because I just pass one argument.... Or am I wrong?
The positional argument isna
takes is self
, because you're calling the method of pd.Dataframe
( change.isna()
). You're passing one argument, but that's the second argument to the function, hence the error.
Take a look at pd.Dataframe.isna
's documentation : there is only self
specified as argument. This is, because isna
actually returns a boolean array where for each element in the dataframe it tells you whether it's a valid value or NA.
if change.iloc[i].isna()[3]:
....
Alternatively, use the function pandas.isna()
, which takes exactly one object as argument:
if pd.isna(change.iloc[i,3]):
....
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.