def to_table(data, bins=None):
 data = np.asarray(data)
 (n_rows, n_cols) = data.shape
 if (bins is None):
  (cat_uni, cat_int) = np.unique(data.ravel(), return_inverse=True)
  n_cat = len(cat_uni)
  data_ = cat_int.reshape(data.shape)
  bins_ = (np.arange((n_cat + 1)) - 0.5)
 elif np.isscalar(bins):
  bins_ = (np.arange((bins + 1)) - 0.5)
  data_ = data
 else:
  bins_ = bins
  data_ = data
 tt = np.histogramdd(data_, ((bins_,) * n_cols))
 return (tt[0], bins_)

def to_table ( data , bins = None ) : data = np . asarray ( data ) ( n_rows , n_cols ) = data . shape if ( bins is None ) : ( cat_uni , cat_int ) = np . unique ( data . ravel ( ) , return_inverse = True ) n_cat = len ( cat_uni ) data_ = cat_int . reshape ( data . shape ) bins_ = ( np . arange ( ( n_cat + 1 ) ) - 0.5 ) elif np . isscalar ( bins ) : bins_ = ( np . arange ( ( bins + 1 ) ) - 0.5 ) data_ = data else : bins_ = bins data_ = data tt = np . histogramdd ( data_ , ( ( bins_ , ) * n_cols ) ) return ( tt [ 0 ] , bins_ )
convert raw data with shape to brings data into correct format for cohens_kappa parameters data : array_like .