How do I use scipy.stats.binned_statistic?

50 views Asked by At

So I have this csv file with a little more than 16k rows and I want to bin average them, the data are temperature and depth data, so I want to make depth bins 0-10, than 10-20 and so on with the temperature means in them.

My idea is to see something like this:

depth temperature
5 20
10 23
15 27

I tried this:

`binned_data = scipy.stats.binned_statistic(data['temperature'], data['pressure'], statistic='mean', bins=1636)

print(binned_data)`

and the output I got was this:

BinnedStatisticResult(statistic=array([ nan, nan, nan, ..., 20.48083333, 13.84529412, 14.27548387]), bin_edges=array([ 2.95 , 2.96304401, 2.97608802, ..., 24.26391198, 24.27695599, 24.29 ]), binnumber=array([1636, 1635, 1636, ..., 1542, 1543, 1543]))

I don't know if I understood this scipy function wrong, but how can I see each bin with the corresponding temperature mean as I intended?

0

There are 0 answers