diff --git a/pandas/core/frame.py b/pandas/core/frame.py index a734baf28464b..4ce9cc5804264 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -708,8 +708,8 @@ def to_dict(self, orient='dict'): elif orient.lower().startswith('r'): return [dict((k, v) for k, v in zip(self.columns, row)) for row in self.values] - else: # pragma: no cover - raise ValueError("outtype %s not understood" % outtype) + else: + raise ValueError("orient '%s' not understood" % orient) def to_gbq(self, destination_table, project_id=None, chunksize=10000, verbose=True, reauth=False): diff --git a/pandas/tests/test_frame.py b/pandas/tests/test_frame.py index d46a219f3b1eb..e8ba97ca4f346 100644 --- a/pandas/tests/test_frame.py +++ b/pandas/tests/test_frame.py @@ -4158,6 +4158,10 @@ def test_to_dict(self): tm.assert_almost_equal(recons_data, expected_records) + def test_to_dict_invalid_orient(self): + df = DataFrame({'A':[0, 1]}) + self.assertRaises(ValueError, df.to_dict, orient='invalid') + def test_to_records_dt64(self): df = DataFrame([["one", "two", "three"], ["four", "five", "six"]],