Skip to content

Commit 1a6939f

Browse files
committed
PERF: Fixed decoding perf issue on pyt3 (GH5441)
1 parent 05cb960 commit 1a6939f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

doc/source/release.rst

+1
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ Bug Fixes
531531
names weren't strings (:issue:`4956`)
532532
- A zero length series written in Fixed format not deserializing properly.
533533
(:issue:`4708`)
534+
- Fixed decoding perf issue on pyt3 (:issue:`5441`)
534535
- Fixed bug in tslib.tz_convert(vals, tz1, tz2): it could raise IndexError
535536
exception while trying to access trans[pos + 1] (:issue:`4496`)
536537
- The ``by`` argument now works correctly with the ``layout`` argument

pandas/io/pytables.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -3972,8 +3972,11 @@ def _unconvert_string_array(data, nan_rep=None, encoding=None):
39723972
# where the passed encoding is actually None)
39733973
encoding = _ensure_encoding(encoding)
39743974
if encoding is not None and len(data):
3975-
f = np.vectorize(lambda x: x.decode(encoding), otypes=[np.object])
3976-
data = f(data)
3975+
try:
3976+
data = data.astype(str).astype(object)
3977+
except:
3978+
f = np.vectorize(lambda x: x.decode(encoding), otypes=[np.object])
3979+
data = f(data)
39773980

39783981
if nan_rep is None:
39793982
nan_rep = 'nan'

0 commit comments

Comments
 (0)