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
If
data
is your dataframe, you can get the mean of all the columns as integers simply with:or, as of version
0.17.0
:Use the round() function. In case of python3 then you don't have to import the math lib. Check out ceil and floor to round up and down respectively. For ceil and floor you need to import the math lib. Cheers and happy coding!
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