From e65d8352efd4650a89e29293b3370eb31468dce7 Mon Sep 17 00:00:00 2001 From: Brock Date: Mon, 7 Dec 2020 15:35:50 -0800 Subject: [PATCH] REF: call _ensure_valid_index inside _sanitize_column --- pandas/core/frame.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index a1582a57e9a71..e9fb981607a6e 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -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 @@ -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) @@ -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) @@ -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