Skip to content

Commit 53e7d29

Browse files
committed
numpy ravel with dataframe test GH#26247
Signed-off-by: Liang Yan <[email protected]>
1 parent 5a1f280 commit 53e7d29

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pandas/tests/arrays/test_array.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,3 +429,22 @@ def test_array_to_numpy_na():
429429
result = arr.to_numpy(na_value=True, dtype=bool)
430430
expected = np.array([True, True])
431431
tm.assert_numpy_array_equal(result, expected)
432+
433+
434+
def test_array_ravel_from_df():
435+
# GH26247
436+
x = np.random.randn(10, 3)
437+
438+
result = np.ravel([pd.DataFrame(batch.reshape(1, 3)) for batch in x])
439+
expected = np.ravel(x)
440+
tm.assert_numpy_array_equal(result, expected)
441+
442+
result = np.ravel(pd.DataFrame(x[0].reshape(1, 3), columns=["x1", "x2", "x3"]))
443+
expected = x[0]
444+
tm.assert_numpy_array_equal(result, expected)
445+
446+
result = np.ravel(
447+
[pd.DataFrame(batch.reshape(1, 3), columns=["x1", "x2", "x3"]) for batch in x]
448+
)
449+
expected = np.ravel(x)
450+
tm.assert_numpy_array_equal(result, expected)

0 commit comments

Comments
 (0)