Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pandas/core/reshape/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ def check_len(item, name: str) -> None:
# columns to prepend to result.
with_dummies = [data.select_dtypes(exclude=dtypes_to_encode)]

for col, pre, sep in zip(data_to_encode.items(), prefix, prefix_sep):
for col, pre, sep in zip(
data_to_encode.items(), prefix, prefix_sep, strict=False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what cases need this? does this indicate a bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just followed the instruction of #62434 (comment) setting strict = True,the CI tests failed.And after checking the output,it means there should be strict = False.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, but the point of adding strict=True is to track down potential bugs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get it,so may i just revert the change I made in the encoding.py?Or should I find some ways to prove it to make setting strict=True can also pass the CI tests?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either way. the latter would be more helpful but harder

):
# col is (column_name, column), use just column data here
dummy = _get_dummies_1d(
col[1],
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/reshape/melt.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def melt(
missing = idx == -1
if missing.any():
missing_labels = [
lab for lab, not_found in zip(labels, missing) if not_found
lab for lab, not_found in zip(labels, missing, strict=True) if not_found
]
raise KeyError(
"The following id_vars or value_vars are not present in "
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/reshape/pivot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,8 +1098,8 @@ def crosstab(
from pandas import DataFrame

data = {
**dict(zip(unique_rownames, index)),
**dict(zip(unique_colnames, columns)),
**dict(zip(unique_rownames, index, strict=True)),
**dict(zip(unique_colnames, columns, strict=True)),
}
df = DataFrame(data, index=common_idx)

Expand Down
Loading