Skip to content

Commit b10f728

Browse files
author
Kyle Barron
committed
More helpful Stata object dtype error. (pandas-dev#23572)
1 parent 011b79f commit b10f728

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pandas/io/stata.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,12 @@ def parse_dates_safe(dates, delta=False, year=False, days=False):
466466
"""
467467

468468

469+
general_object_array_error = """
470+
Writing non-string object columns is not supported. Column '%s' does not
471+
satisfy this restriction.
472+
"""
473+
474+
469475
class PossiblePrecisionLoss(Warning):
470476
pass
471477

@@ -1868,7 +1874,7 @@ def _dtype_to_default_stata_fmt(dtype, column, dta_version=114,
18681874
inferred_dtype = infer_dtype(column.dropna())
18691875
if not (inferred_dtype in ('string', 'unicode') or
18701876
len(column) == 0):
1871-
raise ValueError('Writing general object arrays is not supported')
1877+
raise ValueError(general_object_array_error % column.name)
18721878
itemsize = max_len_string_array(ensure_object(column.values))
18731879
if itemsize > max_str_len:
18741880
if dta_version >= 117:

0 commit comments

Comments
 (0)