From 4e259f45d13e22677c78826b77cd7e37e56e3ae5 Mon Sep 17 00:00:00 2001 From: Guillaume Gay Date: Fri, 12 Jul 2019 17:41:15 +0200 Subject: [PATCH 1/2] adds non regression test for GH27358 --- pandas/tests/frame/test_constructors.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pandas/tests/frame/test_constructors.py b/pandas/tests/frame/test_constructors.py index a3817d3c226f5..547fbfa4fa45d 100644 --- a/pandas/tests/frame/test_constructors.py +++ b/pandas/tests/frame/test_constructors.py @@ -2427,6 +2427,13 @@ class List(list): result = DataFrame(List([List([1, 2, 3]), List([4, 5, 6])])) tm.assert_frame_equal(result, expected) + def test_from_records_series_list_dict(self): + # GH27358 + expected = pd.DataFrame([[{"a": 1, "b": 2}, {"a": 3, "b": 4}]]).T + data = Series([[{"a": 1, "b": 2}], [{"a": 3, "b": 4}]]) + result = pd.DataFrame.from_records(data) + tm.assert_frame_equal(result, expected) + class TestDataFrameConstructorWithDatetimeTZ: def test_from_dict(self): From d9bb6981c9801e303f70b5401d034042946bdda8 Mon Sep 17 00:00:00 2001 From: Guillaume Gay Date: Fri, 12 Jul 2019 18:53:05 +0200 Subject: [PATCH 2/2] changes as requested --- pandas/tests/frame/test_constructors.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pandas/tests/frame/test_constructors.py b/pandas/tests/frame/test_constructors.py index 547fbfa4fa45d..7e6b707f01acf 100644 --- a/pandas/tests/frame/test_constructors.py +++ b/pandas/tests/frame/test_constructors.py @@ -2397,6 +2397,13 @@ def test_from_records_len0_with_columns(self): assert result.index.name == "foo" tm.assert_index_equal(result.columns, expected) + def test_from_records_series_list_dict(self): + # GH27358 + expected = DataFrame([[{"a": 1, "b": 2}, {"a": 3, "b": 4}]]).T + data = Series([[{"a": 1, "b": 2}], [{"a": 3, "b": 4}]]) + result = DataFrame.from_records(data) + tm.assert_frame_equal(result, expected) + def test_to_frame_with_falsey_names(self): # GH 16114 result = Series(name=0).to_frame().dtypes @@ -2427,13 +2434,6 @@ class List(list): result = DataFrame(List([List([1, 2, 3]), List([4, 5, 6])])) tm.assert_frame_equal(result, expected) - def test_from_records_series_list_dict(self): - # GH27358 - expected = pd.DataFrame([[{"a": 1, "b": 2}, {"a": 3, "b": 4}]]).T - data = Series([[{"a": 1, "b": 2}], [{"a": 3, "b": 4}]]) - result = pd.DataFrame.from_records(data) - tm.assert_frame_equal(result, expected) - class TestDataFrameConstructorWithDatetimeTZ: def test_from_dict(self):