Skip to content

Commit f1fb54e

Browse files
committed
Correct pyarrow cast explanation in comment
1 parent 3784b5e commit f1fb54e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pandas/core/strings/object_array.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ def encode_func(x):
267267
if x is str:
268268
return x.encode(encoding=encoding, errors=errors)
269269
else:
270-
# Manage AttributeError: 'pyarrow.lib.LargeStringScalar'
271-
# object has no attribute 'encode'
270+
# If x is a 'pyarrow.lib.LargeStringScalar' it has
271+
# no attribute 'encode' so we cast it
272272
return str(x).encode(encoding=encoding, errors=errors)
273273

274274
return self._str_map(encode_func, dtype=object)

pandas/tests/strings/test_strings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,8 @@ def encode_func(x):
566566
if x is str:
567567
return x.encode("cp1252", "ignore")
568568
else:
569-
# Manage AttributeError: 'pyarrow.lib.LargeStringScalar'
570-
# object has no attribute 'encode'
569+
# If x is a 'pyarrow.lib.LargeStringScalar' it has
570+
# no attribute 'encode' so we cast it
571571
return str(x).encode("cp1252", "ignore")
572572

573573
expected = ser.map(encode_func).astype("object")

0 commit comments

Comments
 (0)