Skip to content

REF: call _ensure_valid_index inside _sanitize_column #38349

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

Merged
merged 1 commit into from
Dec 8, 2020
Merged
Changes from all 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: 1 addition & 3 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3212,7 +3212,6 @@ def _setitem_frame(self, key, value):
self._where(-key, value, inplace=True)

def _iset_item(self, loc: int, value):
self._ensure_valid_index(value)

# technically _sanitize_column expects a label, not a position,
# but the behavior is the same as long as we pass broadcast=False
Expand All @@ -3235,7 +3234,6 @@ def _set_item(self, key, value):
Series/TimeSeries will be conformed to the DataFrames index to
ensure homogeneity.
"""
self._ensure_valid_index(value)
value = self._sanitize_column(key, value)
NDFrame._set_item(self, key, value)

Expand Down Expand Up @@ -3755,7 +3753,6 @@ def insert(self, loc, column, value, allow_duplicates=False) -> None:
"Cannot specify 'allow_duplicates=True' when "
"'self.flags.allows_duplicate_labels' is False."
)
self._ensure_valid_index(value)
value = self._sanitize_column(column, value, broadcast=False)
self._mgr.insert(loc, column, value, allow_duplicates=allow_duplicates)

Expand Down Expand Up @@ -3846,6 +3843,7 @@ def _sanitize_column(self, key, value, broadcast=True):
-------
numpy.ndarray
"""
self._ensure_valid_index(value)

def reindexer(value):
# reindex if necessary
Expand Down