-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Categorical.(get|from)_dummies #34426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
b5ab7f2
f937c96
dd14132
9dc9da5
ac9cec2
0459cb1
65e68c2
1334026
c2240b6
66771bf
4e769da
fe002af
097f2c6
afe8eda
e78158e
4fb1e5e
9fa5494
61567fd
5d724cc
1182ce5
04ca72a
6e4f71a
a761baf
ed58c77
741cf8f
6f199b6
034f8e1
b80f089
0eb936f
8f212e1
bda5265
6e6ddda
9fcebf0
b9908c4
faeec41
e11f28e
742c940
722137d
4945ba8
1f98233
ff01048
604b839
c71e807
6f9272a
8fd4b72
534bc33
0facec6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -451,11 +451,9 @@ def from_dummies( | |
""" | ||
from pandas import Series | ||
|
||
copied = False | ||
to_drop = dummies.columns[isna(dummies.columns.values)] | ||
clbarnes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if len(to_drop): | ||
dummies = dummies.drop(columns=to_drop) | ||
copied = True | ||
|
||
if prefix is None: | ||
cats = dummies.columns | ||
|
@@ -471,7 +469,7 @@ def from_dummies( | |
|
||
df = dummies.astype("boolean") | ||
if fillna is not None: | ||
df = df.fillna(fillna, inplace=copied) | ||
df = df.fillna(fillna) | ||
|
||
row_totals = df.sum(axis=1, skipna=False) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why skipna? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there is no explicit |
||
if row_totals.isna().any(): | ||
|
@@ -481,7 +479,8 @@ def from_dummies( | |
if multicat_rows.any(): | ||
raise ValueError( | ||
"{} record(s) belongs to multiple categories: {}".format( | ||
clbarnes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
multicat_rows.sum(), list(df.index[multicat_rows]), | ||
multicat_rows.sum(), | ||
list(df.index[multicat_rows]), | ||
) | ||
) | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.