Пример #1
0
def test_cummin_masked():
    data = [1, 2, None, 4, 5]
    float_types = ["float32", "float64"]

    for type_ in float_types:
        gs = Series(data).astype(type_)
        ps = pd.Series(data).astype(type_)
        assert_eq(gs.cummin(), ps.cummin())

    for type_ in INTEGER_TYPES:
        gs = Series(data).astype(type_)
        expected = pd.Series([1, 1, np.nan, 1, 1]).astype("float64")
        assert_eq(gs.cummin(), expected)
Пример #2
0
def test_cummin_masked():
    data = [1, 2, None, 4, 5]
    float_types = ["float32", "float64"]
    int_types = ["int8", "int16", "int32", "int64"]

    for type_ in float_types:
        gs = Series(data).astype(type_)
        ps = pd.Series(data).astype(type_)
        assert_eq(gs.cummin(), ps.cummin())

    for type_ in int_types:
        expected = pd.Series([1, 1, -1, 1, 1]).astype(type_)
        gs = Series(data).astype(type_)
        assert_eq(gs.cummin(), expected)
Пример #3
0
def test_cummin(dtype, nelem):
    if dtype == np.int8:
        # to keep data in range
        data = gen_rand(dtype, nelem, low=-2, high=2)
    else:
        data = gen_rand(dtype, nelem)

    decimal = 4 if dtype == np.float32 else 6

    # series
    gs = Series(data)
    ps = pd.Series(data)
    np.testing.assert_array_almost_equal(gs.cummin().to_array(),
                                         ps.cummin(),
                                         decimal=decimal)

    # dataframe series (named series)
    gdf = DataFrame()
    gdf["a"] = Series(data)
    pdf = pd.DataFrame()
    pdf["a"] = pd.Series(data)
    np.testing.assert_array_almost_equal(gdf.a.cummin().to_array(),
                                         pdf.a.cummin(),
                                         decimal=decimal)