MCPcopy Create free account
hub / github.com/dask/dask / test_series_map2

Function test_series_map2

dask/dataframe/tests/test_map.py:41–56  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

39
40
41def test_series_map2():
42 df = pd.DataFrame(
43 {"a": range(9), "b": [4, 5, 6, 1, 2, 3, 0, 0, 0]},
44 index=pd.Index([0, 1, 3, 5, 6, 8, 9, 9, 9], name="myindex"),
45 )
46 ddf = dd.from_pandas(df, npartitions=3)
47 with pytest.warns(UserWarning, match="meta"):
48 assert_eq(ddf.a.map(lambda x: x + 1), df.a.map(lambda x: x + 1))
49 lk = {v: v + 1 for v in df.a.values}
50 assert_eq(ddf.a.map(lk), df.a.map(lk))
51 assert_eq(ddf.b.map(lk), df.b.map(lk))
52 lk = pd.Series(lk)
53 assert_eq(ddf.a.map(lk), df.a.map(lk))
54 assert_eq(ddf.b.map(lk), df.b.map(lk))
55 assert_eq(ddf.b.map(lk, meta=ddf.b), df.b.map(lk))
56 assert_eq(ddf.b.map(lk, meta=("b", "i8")), df.b.map(lk))
57
58
59def test_series_map_meta():

Callers

nothing calls this directly

Calls 2

assert_eqFunction · 0.90
mapMethod · 0.45

Tested by

no test coverage detected