In pandas can you aggregate by mean and round that mean to the nearest int?

Viewed 36253

So I have 169 columns which have been treated to leave 1=for yes and 0= for no, now I need to aggregate the 2 million rows by mean, and the round that results to the nearest int, how could I get that?

The image is just showing that the values per column are either 0 or 1

enter image description here

3 Answers

You can use python's round function to get mean value in nearest integer, for example see below mean of LotArea was rounded to nearest int. avg_lot_size = round(home_data['LotArea'].mean())

if home_data['LotArea'].mean() gives value 100056.89 then avg_lot_size would be= 100057

Related