Home > other >  How to get only the specific value from series or list
How to get only the specific value from series or list

Time:10-17

I have a data of over 600 employees' attendance over a period of month.

Table Sample

I have to get the count of absents of each employee and write it to another excel sheet.

So I initiated a for loop as shown below:

Code Sample

Im storing the value counts in a list and that includes the count of all variables in the row named status in picture 1.

How do I store only the count value of A(absent) in a list so I could use it accordingly.

Note: I know that status.loc['A'] gives the count of absent but when I try to use it in the loop it says key error.

Status.loc['A']

If I can't get the value of A from status.loc , is there a way to extract it from the list i stored it in named absent?

Please help me out! Thanks in advance!!

CodePudding user response:

You should just do error handeling:

try:
    absent.append(status.loc['A'])
except:
    <rest of code here>
  • Related