next time please add sample df.
# import pandas
import pandas as pd
# sample df
d = {'Infection': ['Y', 'N', 'Y', 'Y', 'N', 'Y','N'],'Age': [11, 22, 33, 44, 55, 66, 77]}
df = pd.DataFrame(data=d)
# min max age if Infection == Y
print(df[df['Infection']=='Y']['Age'].min())
print(df[df['Infection']=='Y']['Age'].max())
If I missed the point of your question or you need me to clarify anything let me know. Good luck!
CLICK HERE to find out more related problems solutions.