0

From data in a csv file, I try to obtain using Panda, the sum of the rows of a specific column ("Status_Issue") of the csv file that are:

  • empty rows and
  • rows containing the word "Pending".

Here is the code I used but unfortunately it doesn't work, can you please help me to correct my error.

def count_pending_TaxRegulatory():
df = pd.read_csv("sortdata.csv", header=1)
count1 = (df["Status_Issue"]=="Pending").sum()
count2 = df["Status_Issue"].isna().sum()
result1 = count1 + count2
macropod
  • 12,757
  • 2
  • 9
  • 21
mollieda
  • 69
  • 6
  • What is the error message? Update your post with the output of `print(df.head().to_string())` or `print(df.head().to_dict())` – Corralien Jan 01 '22 at 20:22

1 Answers1

1

sum() function return the sum of the values for the requested axis, so unless "Status_Issue" is only either 1 or 0 (where isna is making things 1 or 0 thus working), it won't work as you wanted. check this out Count number of rows when row contains certain text

blackcat
  • 78
  • 4