Jay
Jay

Reputation: 67

df.iloc function in pandas not workiing

I'm trying to locate all rows that have N/A for a particular column, however my code isn't working...

df_train.iloc[lambda x: x.value.isna()]

Upvotes: 0

Views: 571

Answers (3)

Rostyslav Shevchenko
Rostyslav Shevchenko

Reputation: 201

try:

df_train.loc[df_train.value.isna()]

If you really want to do it with iloc try next one:

df_train.iloc[lambda x: x[x.value.isna()].index]

This is needed because iloc is a purely index-based selection.

Upvotes: 2

Mark Wang
Mark Wang

Reputation: 2757

You are almost there! loc does take callable with a boolean return, so you can do

df_train.loc[lambda x: x.value.isna()]

Upvotes: 0

Renaud
Renaud

Reputation: 2819

Maybe:

df_train[df_train["particularColumnName"].isna()]

Upvotes: 0

Related Questions