def test_cut_drop_duplicates_raises( x, bins, right, precision, duplicates, ordered, include_lowest ): with pytest.raises(ValueError) as excgd: cut( x=x, bins=bins, right=right, precision=precision, duplicates=duplicates, include_lowest=include_lowest, ordered=ordered, ) with pytest.raises(ValueError) as excpd: pd.cut( x=x, bins=bins, right=right, precision=precision, duplicates=duplicates, include_lowest=include_lowest, ordered=ordered, ) assert_eq(str(excgd.value), str(excpd.value))
def test_cut_labels_non_unique( x, bins, right, include_lowest, ordered, precision, labels ): pcat = pd.cut( x=x, bins=bins, right=right, labels=labels, precision=precision, include_lowest=include_lowest, ordered=ordered, ) pindex = pd.CategoricalIndex(pcat) if labels else pcat gindex = cut( x=x, bins=bins, right=right, labels=labels, precision=precision, include_lowest=include_lowest, ordered=ordered, ) assert_eq(pindex, gindex)
def test_cut_drop_duplicates( x, bins, right, precision, duplicates, ordered, include_lowest ): pcat = pd.cut( x=x, bins=bins, right=right, precision=precision, duplicates=duplicates, include_lowest=include_lowest, ordered=ordered, ) pindex = pd.CategoricalIndex(pcat) gindex = cut( x=x, bins=bins, right=right, precision=precision, duplicates=duplicates, include_lowest=include_lowest, ordered=ordered, ) assert_eq(pindex, gindex)
def test_cut_right(x, bins, right, precision): pcat = pd.cut(x=x, bins=bins, right=right, precision=precision,) pindex = pd.CategoricalIndex(pcat) gindex = cut(x=x, bins=bins, right=right, precision=precision,) assert_eq(pindex, gindex)
def test_cut_intervalindex_bin(x, bins, right, precision, duplicates): pcat = pd.cut( x=x, bins=bins, right=right, precision=precision, duplicates=duplicates, ) pindex = pd.CategoricalIndex(pcat) gindex = cut( x=x, bins=bins, right=right, precision=precision, duplicates=duplicates, ) assert_eq(pindex, gindex)
def test_cut_series(x, bins, right, include_lowest, ordered, precision): pcat = pd.cut( x=x, bins=bins, right=right, precision=precision, include_lowest=include_lowest, ordered=ordered, ) gcat = cut( x=x, bins=bins, right=right, precision=precision, include_lowest=include_lowest, ordered=ordered, ) assert_eq(pcat, gcat)
def test_cut_basic(x, bins, right, include_lowest, ordered, precision): # will test optional labels, retbins and duplicates seperately # they need more specific parameters to work pcat = pd.cut( x=x, bins=bins, right=right, precision=precision, include_lowest=include_lowest, ordered=ordered, ) pindex = pd.CategoricalIndex(pcat) gindex = cut( x=x, bins=bins, right=right, precision=precision, include_lowest=include_lowest, ordered=ordered, ) assert_eq(pindex, gindex)