Skip to content

Commit

Permalink
ENH: Improve error message for empty object array
Browse files Browse the repository at this point in the history
Improve the error message shown when an object array is empty

closes #23572
  • Loading branch information
bashtage committed Nov 15, 2018
1 parent c55057f commit 3eb95fd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,12 @@ def _dtype_to_default_stata_fmt(dtype, column, dta_version=114,
inferred_dtype = infer_dtype(column.dropna())
if not (inferred_dtype in ('string', 'unicode') or
len(column) == 0):
raise ValueError('Writing general object arrays is not supported')
raise ValueError('Only string-like object arrays containing all '
'strings or a mix of strings and None can be '
'exported. Object arrays containing only null '
'values are prohibited. Other object types'
'cannot be exported and must first be converted '
'to one of the supported types.')
itemsize = max_len_string_array(ensure_object(column.values))
if itemsize > max_str_len:
if dta_version >= 117:
Expand Down

0 comments on commit 3eb95fd

Please sign in to comment.