MCPcopy
hub / github.com/pandas-dev/pandas / test_map_callable

Function test_map_callable

pandas/tests/series/methods/test_map.py:42–67  ·  view source on GitHub ↗
(datetime_series, engine)

Source from the content-addressed store, hash-verified

40
41
42def test_map_callable(datetime_series, engine): # noqa: F811
43 with np.errstate(all="ignore"):
44 tm.assert_series_equal(
45 datetime_series.map(np.sqrt, engine=engine), np.sqrt(datetime_series)
46 )
47
48 # map function element-wise
49 tm.assert_series_equal(
50 datetime_series.map(math.exp, engine=engine), np.exp(datetime_series)
51 )
52
53 # empty series
54 s = Series(dtype=object, name="foo", index=Index([], name="bar"))
55 rs = s.map(lambda x: x, engine=engine)
56 tm.assert_series_equal(s, rs)
57
58 # check all metadata (GH 9322)
59 assert s is not rs
60 assert s.index is rs.index
61 assert s.dtype == rs.dtype
62 assert s.name == rs.name
63
64 # index but no data
65 s = Series(index=[1, 2, 3], dtype=np.float64)
66 rs = s.map(lambda x: x, engine=engine)
67 tm.assert_series_equal(s, rs)
68
69
70def test_map_same_length_inference_bug():

Callers

nothing calls this directly

Calls 4

mapMethod · 0.95
SeriesClass · 0.90
IndexClass · 0.90
mapMethod · 0.45

Tested by

no test coverage detected