Skip to content

Commit 904576a

Browse files
committed
ENH: Improve error message for empty object array
Improve the error message shown when an object array is empty closes pandas-dev#23572
1 parent a23f901 commit 904576a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pandas/io/stata.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1868,7 +1868,12 @@ def _dtype_to_default_stata_fmt(dtype, column, dta_version=114,
18681868
inferred_dtype = infer_dtype(column.dropna())
18691869
if not (inferred_dtype in ('string', 'unicode') or
18701870
len(column) == 0):
1871-
raise ValueError('Writing general object arrays is not supported')
1871+
raise ValueError('Only string-like object arrays containing all '
1872+
'strings or a mix of strings and None can be '
1873+
'exported. Object arrays containing only null '
1874+
'values are prohibited. Other object types'
1875+
'cannot be exported and must first be converted '
1876+
'to one of the supported types.')
18721877
itemsize = max_len_string_array(ensure_object(column.values))
18731878
if itemsize > max_str_len:
18741879
if dta_version >= 117:

0 commit comments

Comments
 (0)