Skip to content

Commit 8ede5d9

Browse files
committed
BUG: unsupported type Interval when writing dataframe to excel
1 parent d3f7d2a commit 8ede5d9

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

doc/source/whatsnew/v0.23.0.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,3 +549,4 @@ Other
549549
^^^^^
550550

551551
- Improved error message when attempting to use a Python keyword as an identifier in a ``numexpr`` backed query (:issue:`18221`)
552+
- Bug in :func:`DataFrame.to_excel` where an exception was raised indicating unsupported type when writing a data frame containing a column of Interval type (:issue:`19242`)

pandas/io/excel.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from distutils.version import LooseVersion
3333
from pandas.util._decorators import Appender, deprecate_kwarg
3434
from textwrap import fill
35+
from pandas._libs.interval import Interval
3536

3637
__all__ = ["read_excel", "ExcelWriter", "ExcelFile"]
3738

@@ -788,6 +789,8 @@ def _conv_value(val):
788789
val = "{val}".format(val=val)
789790
elif is_list_like(val):
790791
val = str(val)
792+
elif isinstance(val, Interval):
793+
val = str(val)
791794

792795
return val
793796

0 commit comments

Comments
 (0)