예제 #1
0
def test_series_map_callable_numeric_random_dtype_change():
    # Test for changing the out_dtype using applymap

    data = list(range(10))

    sr = Series(data)
    pdsr = pd.Series(data)

    got = sr.map(lambda x: float(x))
    expect = pdsr.map(lambda x: float(x))

    # Check
    assert_eq(expect, got)
예제 #2
0
def test_series_map_callable_numeric_random(nelem):
    # Generate data
    np.random.seed(0)
    data = np.random.random(nelem) * 100

    sr = Series(data)
    pdsr = pd.Series(data)

    # Call applymap
    got = sr.map(lambda x: (floor(x) + 1 if x - floor(x) >= 0.5 else floor(x)))
    expect = pdsr.map(lambda x: (floor(x) + 1
                                 if x - floor(x) >= 0.5 else floor(x)))

    # Check
    assert_eq(expect, got, check_dtype=False)