Code has been added to clipboard!

Getting the Number of Even Numbers

Example
def count_even_numbers(series):
  return len([elem for elem in series if elem % 2 == 0 ])
df.groupby('Employee')['Age'].apply(count_even_numbers).reset_index(name='num_even_numbers')