We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a3d353f commit 35261c0Copy full SHA for 35261c0
pandas/tests/frame/constructors/test_from_records.py
@@ -469,3 +469,26 @@ def test_from_records_empty2(self):
469
470
alt = DataFrame(arr)
471
tm.assert_frame_equal(alt, expected)
472
+
473
+ def test_from_records_structured_array(self):
474
+ # GH 59717
475
+ data = np.array(
476
+ [
477
+ ("John", 25, "New York", 50000),
478
+ ("Jane", 30, "San Francisco", 75000),
479
+ ("Bob", 35, "Chicago", 65000),
480
+ ("Alice", 28, "Los Angeles", 60000),
481
+ ],
482
+ dtype=[("name", "U10"), ("age", "i4"), ("city", "U15"), ("salary", "i4")],
483
+ )
484
485
+ actual_result = DataFrame.from_records(data, columns=["name", "salary", "city"])
486
487
+ modified_data = {
488
+ "name": ["John", "Jane", "Bob", "Alice"],
489
+ "salary": np.array([50000, 75000, 65000, 60000], dtype="int32"),
490
+ "city": ["New York", "San Francisco", "Chicago", "Los Angeles"],
491
+ }
492
+ expected_result = DataFrame(modified_data)
493
494
+ tm.assert_frame_equal(actual_result, expected_result)
0 commit comments