|
8 | 8 | import numpy as np
|
9 | 9 |
|
10 | 10 | from pandas._libs import internals as libinternals, lib, tslib, tslibs
|
11 |
| -from pandas._libs.tslibs import Timedelta, conversion, timezones |
| 11 | +from pandas._libs.tslibs import Timedelta, conversion |
12 | 12 | import pandas.compat as compat
|
13 | 13 | from pandas.compat import range, zip
|
14 | 14 | from pandas.errors import AbstractMethodError
|
@@ -3156,23 +3156,13 @@ def setitem(self, indexer, value):
|
3156 | 3156 | # https://github.com/pandas-dev/pandas/issues/24020
|
3157 | 3157 | # Need a dedicated setitem until #24020 (type promotion in setitem
|
3158 | 3158 | # for extension arrays) is designed and implemented.
|
3159 |
| - maybe_tz = getattr(value, 'tz', None) |
3160 |
| - return_object = ( |
3161 |
| - (maybe_tz |
3162 |
| - and not timezones.tz_compare(self.values.tz, maybe_tz)) or |
3163 |
| - (lib.is_scalar(value) |
3164 |
| - and not isna(value) |
3165 |
| - and not value == tslib.iNaT |
3166 |
| - and not (isinstance(value, self.values._scalar_type) and |
3167 |
| - timezones.tz_compare(self.values.tz, maybe_tz))) |
3168 |
| - ) |
3169 |
| - |
3170 |
| - if return_object: |
| 3159 | + try: |
| 3160 | + return super(DatetimeTZBlock, self).setitem(indexer, value) |
| 3161 | + except ValueError: |
3171 | 3162 | newb = make_block(self.values.astype(object),
|
3172 | 3163 | placement=self.mgr_locs,
|
3173 | 3164 | klass=ObjectBlock,)
|
3174 | 3165 | return newb.setitem(indexer, value)
|
3175 |
| - return super(DatetimeTZBlock, self).setitem(indexer, value) |
3176 | 3166 |
|
3177 | 3167 |
|
3178 | 3168 | # -----------------------------------------------------------------
|
|
0 commit comments