File tree 2 files changed +8
-5
lines changed
2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -319,6 +319,7 @@ Performance improvements
319
319
~~~~~~~~~~~~~~~~~~~~~~~~
320
320
- Performance improvement in :func: `.testing.assert_frame_equal ` and :func: `.testing.assert_series_equal ` (:issue: `55949 `, :issue: `55971 `)
321
321
- Performance improvement in :func: `concat ` with ``axis=1 `` and objects with unaligned indexes (:issue: `55084 `)
322
+ - Performance improvement in :func: `get_dummies ` (:issue: `56089 `)
322
323
- Performance improvement in :func: `merge_asof ` when ``by `` is not ``None `` (:issue: `55580 `, :issue: `55678 `)
323
324
- Performance improvement in :func: `read_stata ` for files with many variables (:issue: `55515 `)
324
325
- Performance improvement in :func: `to_dict ` on converting DataFrame to dictionary (:issue: `50990 `)
Original file line number Diff line number Diff line change @@ -321,13 +321,15 @@ def get_empty_frame(data) -> DataFrame:
321
321
return concat (sparse_series , axis = 1 , copy = False )
322
322
323
323
else :
324
- # take on axis=1 + transpose to ensure ndarray layout is column-major
325
- eye_dtype : NpDtype
324
+ # ensure ndarray layout is column-major
325
+ shape = len (codes ), number_of_cols
326
+ dummy_dtype : NpDtype
326
327
if isinstance (_dtype , np .dtype ):
327
- eye_dtype = _dtype
328
+ dummy_dtype = _dtype
328
329
else :
329
- eye_dtype = np .bool_
330
- dummy_mat = np .eye (number_of_cols , dtype = eye_dtype ).take (codes , axis = 1 ).T
330
+ dummy_dtype = np .bool_
331
+ dummy_mat = np .zeros (shape = shape , dtype = dummy_dtype , order = "F" )
332
+ dummy_mat [np .arange (len (codes )), codes ] = 1
331
333
332
334
if not dummy_na :
333
335
# reset NaN GH4446
You can’t perform that action at this time.
0 commit comments