[Tutor] binning data and calculating means of classes

Wolfgang Maier wolfgang.maier at biologie.uni-freiburg.de
Wed Jul 23 11:34:30 CEST 2014


On 07/23/2014 11:28 AM, Wolfgang Maier wrote:
>
> breakpoints = [your_list_of breakpoints]
> large_value_buffer = []
> int_list_iter = iter(int_list) # see comment below
> for breakpoint in breakpoints:
>      sublist = large_value_buffer
>      for value in int_list_iter:
>          if value < breakpoint:
>              sublist.append(value)
>              if large_value_buffer:
>                  large_value_buffer = []
>          else:
>              if sublist:
>                  print(sum(sublist)/len(sublist))
>                  large_value_buffer.append(value)

oops, the last line above needs outdenting by one level.

>              break
>




More information about the Tutor mailing list