|
17 | 17 | from pandas.core.dtypes.common import (
|
18 | 18 | _TD_DTYPE, ensure_object, is_array_like, is_datetime64_dtype,
|
19 | 19 | is_datetime64_ns_dtype, is_datetime64tz_dtype, is_float_dtype,
|
20 |
| - is_list_like, is_period_dtype, pandas_dtype) |
| 20 | + is_period_dtype, pandas_dtype) |
21 | 21 | from pandas.core.dtypes.dtypes import PeriodDtype
|
22 | 22 | from pandas.core.dtypes.generic import ABCIndexClass, ABCPeriodIndex, ABCSeries
|
23 | 23 | from pandas.core.dtypes.missing import isna, notna
|
@@ -362,50 +362,6 @@ def _formatter(self, boxed=False):
|
362 | 362 | return str
|
363 | 363 | return "'{}'".format
|
364 | 364 |
|
365 |
| - def __setitem__( |
366 |
| - self, |
367 |
| - key, # type: Union[int, Sequence[int], Sequence[bool], slice] |
368 |
| - value # type: Union[NaTType, Period, Sequence[Period]] |
369 |
| - ): |
370 |
| - # type: (...) -> None |
371 |
| - # n.b. the type on `value` is a bit too restrictive. |
372 |
| - # we also accept a sequence of stuff coercible to a PeriodArray |
373 |
| - # by period_array, which includes things like ndarray[object], |
374 |
| - # ndarray[datetime64ns]. I think ndarray[int] / ndarray[str] won't |
375 |
| - # work, since the freq can't be inferred. |
376 |
| - if is_list_like(value): |
377 |
| - is_slice = isinstance(key, slice) |
378 |
| - if (not is_slice |
379 |
| - and len(key) != len(value) |
380 |
| - and not com.is_bool_indexer(key)): |
381 |
| - msg = ("shape mismatch: value array of length '{}' does not " |
382 |
| - "match indexing result of length '{}'.") |
383 |
| - raise ValueError(msg.format(len(key), len(value))) |
384 |
| - if not is_slice and len(key) == 0: |
385 |
| - return |
386 |
| - |
387 |
| - value = period_array(value) |
388 |
| - |
389 |
| - if self.freqstr != value.freqstr: |
390 |
| - msg = DIFFERENT_FREQ_INDEX.format(self.freqstr, value.freqstr) |
391 |
| - raise IncompatibleFrequency(msg) |
392 |
| - |
393 |
| - value = value.asi8 |
394 |
| - elif isinstance(value, Period): |
395 |
| - |
396 |
| - if self.freqstr != value.freqstr: |
397 |
| - msg = DIFFERENT_FREQ_INDEX.format(self.freqstr, value.freqstr) |
398 |
| - raise IncompatibleFrequency(msg) |
399 |
| - |
400 |
| - value = value.ordinal |
401 |
| - elif isna(value): |
402 |
| - value = iNaT |
403 |
| - else: |
404 |
| - msg = ("'value' should be a 'Period', 'NaT', or array of those. " |
405 |
| - "Got '{}' instead.".format(type(value).__name__)) |
406 |
| - raise TypeError(msg) |
407 |
| - self._data[key] = value |
408 |
| - |
409 | 365 | @Appender(dtl.DatetimeLikeArrayMixin._validate_fill_value.__doc__)
|
410 | 366 | def _validate_fill_value(self, fill_value):
|
411 | 367 | if isna(fill_value):
|
|
0 commit comments