# Data Analysis with Python Projects - Demographic Data Analyzer

### Tell us what’s happening:

Hello!

Problem: Calculating the mean male age yields ‘inf’.

My code seems to work on my local python environment but breaks in Gitpod. I can’t seem to calculate the average male age since adding up all the ages or using .mean() yields infinity. Using “df[df[‘sex’]==‘Male’][‘age’].mean().round(1)” yields “inf”. Using total_age = int(df.loc[df[‘sex’] == ‘Male’][‘age’].sum()) yields extremely large numbers. How can I fix this?

Thank you very much for reading,
Cheers!

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0`

### Challenge Information:

Data Analysis with Python Projects - Demographic Data Analyzer

Can you share your full code please? Or a screenshot showing the problem?

I tested your code and got this result

``````import pandas as pd
df[df['sex']=='Male']['age'].mean().round(1)

>>> 39.4
``````

I run the following code:

``````import pandas as pd

average_age_men = df[df['sex'] == 'Male']['age'].mean()
print(average_age_men)
``````

This code prints inf. Below is a screenshot:

Surprisingly your code seems to work, so I guess the problem is the “names” part?

I tested:

``````import pandas as pd
import numpy as np

average_age_men = df[df['sex'] == 'Male']['age'].mean()
print(average_age_men)

print(df[df['sex']=='Male']['age'].mean().round(1))
``````

and got: