0

I have a dataset where apparently there are no null values:

dataset.isnull().sum()
Patient           0
City              0
DOB               0
Gender            0
Gender_isspace    0
dtype: int64

However, if a I do for example:

sns.countplot(data=Patients, x='Gender')

There are three columns, M, F and another column with no name and at least 25% of the values.

How can I select this missing values? And delete them?

0

2 Answers 2

1

Create a boolean mask to get 'M', 'F' rows and reverse the mask:

df[~dataset['Gender'].isin(['M', 'F'])]
Sign up to request clarification or add additional context in comments.

Comments

1

You can use the .dropna() method on a dataframe to remove the rows with NaN values or empty strings.

So basically you can do something like, assuming your dataframe is named Patients

Patients.dropna(subset=['M', 'F', 'column3'], inplace=True)

You can view the exact column name using:

print(Patients)

or

Patients.head()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.