Skip to content

Commit 0d2ef67

Browse files
committed
Merge pull request #4732 from jtratner/change-bare-exceptions-pt-3
CLN: Improve Exceptions in core/frame and testing in test_frame and test_multilievel
2 parents 3a2fe0b + db74b2a commit 0d2ef67

File tree

17 files changed

+457
-453
lines changed

17 files changed

+457
-453
lines changed

doc/source/release.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ pandas 0.13
7171
when the key is a column
7272
- Support for using a ``DatetimeIndex/PeriodsIndex`` directly in a datelike calculation
7373
e.g. s-s.index (:issue:`4629`)
74-
- Better/cleaned up exceptions in core/common, io/excel and core/format.
75-
(:issue:`4721`, :issue:`3954`)
74+
- Better/cleaned up exceptions in core/common, io/excel and core/format
75+
(:issue:`4721`, :issue:`3954`), as well as cleaned up test cases in
76+
tests/test_frame, tests/test_multilevel (:issue:`4732`).
7677

7778
**API Changes**
7879

@@ -143,9 +144,10 @@ pandas 0.13
143144
now returns a ``MultiIndex`` rather than an ``Index``. (:issue:`4039`)
144145

145146
- Infer and downcast dtype if ``downcast='infer'`` is passed to ``fillna/ffill/bfill`` (:issue:`4604`)
146-
- Factored out excel_value_to_python_value from ExcelFile::_parse_excel (:issue:`4589`)
147147
- ``__nonzero__`` for all NDFrame objects, will now raise a ``ValueError``, this reverts back to (:issue:`1073`, :issue:`4633`)
148148
behavior.
149+
- ``DataFrame.update()`` no longer raises a ``DataConflictError``, it now
150+
will raise a ``ValueError`` instead (if necessary) (:issue:`4732`)
149151

150152
**Internal Refactoring**
151153

pandas/compat/__init__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,25 @@ def __and__(self, other):
665665
else:
666666
from collections import OrderedDict, Counter
667667

668+
if PY3:
669+
def raise_with_traceback(exc, traceback=Ellipsis):
670+
if traceback == Ellipsis:
671+
_, _, traceback = sys.exc_info()
672+
raise exc.with_traceback(traceback)
673+
else:
674+
# this version of raise is a syntax error in Python 3
675+
exec("""
676+
def raise_with_traceback(exc, traceback=Ellipsis):
677+
if traceback == Ellipsis:
678+
_, _, traceback = sys.exc_info()
679+
raise exc, None, traceback
680+
""")
681+
682+
raise_with_traceback.__doc__ = (
683+
"""Raise exception with existing traceback.
684+
If traceback is not passed, uses sys.exc_info() to get traceback."""
685+
)
686+
668687
# http://stackoverflow.com/questions/4126348
669688
# Thanks to @martineau at SO
670689

pandas/core/format.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -825,9 +825,8 @@ def __init__(self, obj, path_or_buf, sep=",", na_rep='', float_format=None,
825825

826826
# validate mi options
827827
if self.has_mi_columns:
828-
# guarded against in to_csv itself
829-
if cols is not None: # pragma: no cover
830-
raise AssertionError("cannot specify cols with a multi_index on the columns")
828+
if cols is not None:
829+
raise TypeError("cannot specify cols with a MultiIndex on the columns")
831830

832831
if cols is not None:
833832
if isinstance(cols,Index):

0 commit comments

Comments
 (0)