tacco.utils.bin

bin(data, bin_size, position_keys=['x', 'y'], bin_keys=None, shift=None)[source]

Bins points in position space.

Parameters:
  • data – A DataFrame.

  • bin_size – The spatial size of a bin. Bins are of the same size in all dimensions.

  • position_keys – Array-like of column keys which contain the position of the points.

  • bin_keys – The names of the columns to contain the bin assignment. Has to be of the same length as position_keys. If None, a dataframe of bin assignments is returned.

  • shift – An array-like of the same length as position_keys, giving the shift of the start point of the bin grid in every dimension. If None, then no shift is used and the bin grid starts at the minimum value in each dimension.

Returns:

Depending on bin_key returns either a DataFrame of bin assignments or the updated input data contining the bin assignments under bin_keys.