Skip to content

Commit d4f39d5

Browse files
committed
Updating error message to include more details about dataframe
1 parent faf3bbb commit d4f39d5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pandas/core/indexing.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,7 +1989,10 @@ def _setitem_with_indexer_split_path(self, indexer, value, name: str):
19891989
return self._setitem_with_indexer((pi, info_axis[0]), value[0])
19901990

19911991
raise ValueError(
1992-
"Must have equal len keys and value when setting with an iterable"
1992+
f"Length mismatch when setting Dataframe with an iterable: "
1993+
f"{len(pi)} keys vs {len(value)} values. "
1994+
f"Keys: {pi}, Values: {value}. "
1995+
f"Both must have the same length."
19931996
)
19941997

19951998
elif lplane_indexer == 0 and len(value) == len(self.obj.index):
@@ -2017,7 +2020,10 @@ def _setitem_with_indexer_split_path(self, indexer, value, name: str):
20172020

20182021
else:
20192022
raise ValueError(
2020-
"Must have equal len keys and value when setting with an iterable"
2023+
f"Length mismatch when setting Dataframe with an iterable: "
2024+
f"{len(pi)} keys vs {len(value)} values. "
2025+
f"Keys: {pi}, Values: {value}. "
2026+
f"Both must have the same length."
20212027
)
20222028

20232029
else:

0 commit comments

Comments
 (0)