We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cb58dbb commit 6100425Copy full SHA for 6100425
doc/source/whatsnew/v1.2.0.rst
@@ -205,6 +205,7 @@ Deprecations
205
Performance improvements
206
~~~~~~~~~~~~~~~~~~~~~~~~
207
208
+- Performance improvements when creating Series with dtype `str` or :class:`StringDtype` from array with many string elements (:issue:`36304`)
209
- Performance improvement in :meth:`GroupBy.agg` with the ``numba`` engine (:issue:`35759`)
210
-
211
pandas/_libs/lib.pyx
@@ -655,6 +655,10 @@ cpdef ndarray[object] ensure_string_array(
655
656
for i in range(n):
657
val = result[i]
658
+
659
+ if isinstance(val, str):
660
+ continue
661
662
if not checknull(val):
663
result[i] = str(val)
664
else:
0 commit comments