Skip to content

Commit 85c1231

Browse files
Licht-Twesm
authored andcommitted
BUG: Fix Pandas data SerDe with Unicode column names in Python 2.7
1 parent c49636d commit 85c1231

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

python/pyarrow/pandas_compat.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,12 @@ def get_column_metadata(column, name, arrow_type, field_name):
170170
)
171171
)
172172

173+
if not isinstance(field_name, six.string_types):
174+
field_name = str(field_name)
175+
173176
return {
174177
'name': name,
175-
'field_name': str(field_name),
178+
'field_name': field_name,
176179
'pandas_type': logical_type,
177180
'numpy_type': string_dtype,
178181
'metadata': extra_metadata,
@@ -560,9 +563,14 @@ def table_to_blockmanager(options, table, memory_pool, nthreads=1,
560563

561564
column_strings = [x.name for x in block_table.itercolumns()]
562565
if columns:
563-
columns_name_dict = {
564-
c.get('field_name', str(c['name'])): c['name'] for c in columns
565-
}
566+
columns_name_dict = {}
567+
for c in columns:
568+
column_name = c['name']
569+
if not isinstance(column_name, six.text_type):
570+
column_name = str(column_name)
571+
572+
columns_name_dict[c.get('field_name', column_name)] = c['name']
573+
566574
columns_values = [
567575
columns_name_dict.get(name, name) for name in column_strings
568576
]

0 commit comments

Comments
 (0)