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

Function test_map_box

pandas/tests/frame/methods/test_map.py:132–158  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

130
131
132def test_map_box():
133 # ufunc will not be boxed. Same test cases as the test_map_box
134 df = DataFrame(
135 {
136 "a": [Timestamp("2011-01-01"), Timestamp("2011-01-02")],
137 "b": [
138 Timestamp("2011-01-01", tz="US/Eastern"),
139 Timestamp("2011-01-02", tz="US/Eastern"),
140 ],
141 "c": [pd.Timedelta("1 days"), pd.Timedelta("2 days")],
142 "d": [
143 pd.Period("2011-01-01", freq="M"),
144 pd.Period("2011-01-02", freq="M"),
145 ],
146 }
147 )
148
149 result = df.map(lambda x: type(x).__name__)
150 expected = DataFrame(
151 {
152 "a": ["Timestamp", "Timestamp"],
153 "b": ["Timestamp", "Timestamp"],
154 "c": ["Timedelta", "Timedelta"],
155 "d": ["Period", "Period"],
156 }
157 )
158 tm.assert_frame_equal(result, expected)
159
160
161def test_frame_map_dont_convert_datetime64(unit):

Callers

nothing calls this directly

Calls 2

mapMethod · 0.95
DataFrameClass · 0.90

Tested by

no test coverage detected