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

Function test_multi_index_columns

pandas/tests/frame/methods/test_explode.py:107–123  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

105
106
107def test_multi_index_columns():
108 df = pd.DataFrame(
109 {("A", 1): np.array([[0, 1, 2], np.nan, [], (3, 4)], dtype=object), ("A", 2): 1}
110 )
111
112 result = df.explode(("A", 1))
113 expected = pd.DataFrame(
114 {
115 ("A", 1): pd.Series(
116 [0, 1, 2, np.nan, np.nan, 3, 4],
117 index=pd.Index([0, 0, 0, 1, 2, 3, 3]),
118 dtype=object,
119 ),
120 ("A", 2): 1,
121 }
122 )
123 tm.assert_frame_equal(result, expected)
124
125
126def test_usecase():

Callers

nothing calls this directly

Calls 2

explodeMethod · 0.95
arrayMethod · 0.45

Tested by

no test coverage detected