Skip to content

str.cat not working with binary data on Python3 #22721

Closed
@h-vetinari

Description

@h-vetinari

In Python 2, the following works:

s = pd.Series(np.array(list('abc'), 'S1').astype(object))
t = pd.Series(np.array(list('def'), 'S1').astype(object))
s.str.cat(t)
# 0    b'ad'
# 1    b'be'
# 2    b'cf'
# dtype: object

whereas in Python 3, s.str.cat(t) yields:

TypeError: sequence item 0: expected str instance, bytes found

Clearly, Python 3 fundamentally changed the separation between bytes and strings, but in principle, there is no reason (other than implementation) why this should not have the same result in Python 3 as in Python 2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs DiscussionRequires discussion from core team before further action

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions