Given CSV data of employees (Name, Department, Years of Experience), perform an operation such as finding the maximum experience or counting employees in a department, treating the data as erroneous: fields may be empty or of the wrong type and must be ignored in aggregations.
Asked in the HackerRank coding round stage. The input is a CSV string with a header row. Implement employee_aggregate(csv_data, operation, department=None): return the maximum valid experience for "max_experience", or the count of valid employees in department for "count_department". A valid row has exactly three nonempty fields, a nonnegative integer experience, and a matching department when counting. Return None when no valid experience exists.
def employee_aggregate(csv_data, operation, department=None):