Error while using mean()

Screen Link:

My Code:

taxi_modified[550:552,7] = taxi_modified.mean(taxi_modified[:,5])

What I expected to happen:
To have the mean of column 6 stored in cells [550,7] and [551,7]

What actually happened:

TypeError: only integer scalar arrays can be converted to a scalar index

correct code is taxi_modified[550:552,7] = taxi_modified[:,7].mean(), Can somebody tells me why?

Why there is error in my code? what is the difference?

Hi @muhammedkorain,

The function mean, applied to Series objects or dataframes, has the following syntax: Series.mean() or df.mean(), correspondingly.

Then, why did you write taxi_modified[:,5], if we want to find the mean of the column 7.

To sum up the above: to find the mean of the column 7, practically representing a Series object, we have to apple the mean() function on that Series object, exactly how it’s implemented in the solution code.