# Help with round()

how does `round()` work in this case where

``````    average_age_men = df[df['race']=='Male']
['age'].mean().round(1)
``````

its rounding it to the tens place
so 6.798787 as an example would be 6.8

round(1) rounds to the tens place
round(2) rounds to the hundreds place
and so on

2 Likes

Hey @VIctorObuon welcome to the forums!

The number inside the round tells you how many decimal places you want to round to (i.e 1 is 0.1, 2 is 0.01, 3 is 0.001, etc). Normally if you don’t have anything before the round the first digit would be the variable then the decimal place.

``````round(my_variable, 5)
``````

In this case you would round `my_variable` to the decimal place 5 (0.00001). If `my_variable` is equal to 7.500828578 and you had the five it would now be 7.50083 since 5 and up rounds up and 4 and below rounds down. Hope you have a great day !

3 Likes

I like how you just casually slide that into the comment 2 Likes

@DefendyPug I don’t know why Replit.ask is just so addicting trying to get the high numbers XD. I also notice you climbing up the ranks quickly, nice job !

1 Like

Gracias! I wish I found this place sooner, I’ve learned a lot from here.

1 Like