0

I have a data as under in a pandas dataframe [Original shape of the data : 149347 rows and 2 columns]. Purpose includes a text/strings and employeeID includes floats.

enter image description here

Purpose : Text,Text,Text, ,Text,Text, , ,Text | Employee : 1,2,3,4,5,6,7,8,9

I want to create a subset of the data, having only blanks "purpose" and also include relevant employee ID's against such blanks as shown under.

enter image description here

Code used to achieve the above

null_Values = sample['Purpose'].isnull()
# Employee IDs against null values
null_Values['Employee ID'].value_counts()

I understand the error in the above code, however unable to achieve the purpose mentioned.

2
  • Can you edit your question and put the sample data in text form (so we can copy-paste it)? Also, the blanks are empty strings ("")? Or NaNs? Commented Jul 20, 2021 at 10:25
  • Blanks are empty strings. (Blank row as shown in the pic and no entries in the same) Commented Jul 20, 2021 at 10:33

2 Answers 2

1

Try:

print(df[df.Purpose.eq("")])

Prints:

  Purpose  Employee
2                 3
4                 5

df used:

  Purpose  Employee
0    Text         1
1    Text         2
2                 3
3    Text         4
4                 5
Sign up to request clarification or add additional context in comments.

2 Comments

I tried the above, Im getting empty dataframe, however I tried the below code null_Entries = sample[sample['Purpose'].isnull()] print(null_Entries)
@Sid From the doctext of .isnull(): "Characters such as empty strings '' or numpy.inf are not considered NA values"
0

df :

  Purpose  Employee
0    Text         1
1    Text         2
2                 3
3    Text         4
4                 5

Answer:

print(df[df.Purpose.isna()])

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.