Skip to content

Commit 154096f

Browse files
PERF: get_dummies create array of 0/1s with appropriate layout for internals (#40299)
1 parent 8a8df02 commit 154096f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pandas/core/reshape/reshape.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,8 @@ def get_empty_frame(data) -> DataFrame:
10391039
return out
10401040

10411041
else:
1042-
dummy_mat = np.eye(number_of_cols, dtype=dtype).take(codes, axis=0)
1042+
# take on axis=1 + transpose to ensure ndarray layout is column-major
1043+
dummy_mat = np.eye(number_of_cols, dtype=dtype).take(codes, axis=1).T
10431044

10441045
if not dummy_na:
10451046
# reset NaN GH4446

0 commit comments

Comments
 (0)