File tree 2 files changed +8
-2
lines changed
2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -347,6 +347,7 @@ Other Deprecations
347
347
Performance improvements
348
348
~~~~~~~~~~~~~~~~~~~~~~~~
349
349
- Performance improvement in :meth: `.GroupBy.sample `, especially when ``weights `` argument provided (:issue: `34483 `)
350
+ - Performance improvement when converting non-string arrays to string arrays (:issue: `34483 `)
350
351
- Performance improvement in :meth: `.GroupBy.transform ` for user-defined functions (:issue: `41598 `)
351
352
- Performance improvement in constructing :class: `DataFrame ` objects (:issue: `42631 `)
352
353
- Performance improvement in :meth: `GroupBy.shift ` when ``fill_value `` argument is provided (:issue: `26615 `)
Original file line number Diff line number Diff line change @@ -727,14 +727,19 @@ cpdef ndarray[object] ensure_string_array(
727
727
continue
728
728
729
729
if not checknull(val):
730
- result[i] = str (val)
730
+ if not isinstance (val, np.floating):
731
+ # f"{val}" is faster than str(val)
732
+ result[i] = f" {val}"
733
+ else :
734
+ # f"{val}" is not always equivalent to str(val) for floats
735
+ result[i] = str (val)
731
736
else :
732
737
if convert_na_value:
733
738
val = na_value
734
739
if skipna:
735
740
result[i] = val
736
741
else :
737
- result[i] = str ( val)
742
+ result[i] = f " { val} "
738
743
739
744
return result
740
745
You can’t perform that action at this time.
0 commit comments