API: require timezone match in DatetimeArray.shift
State: closed

- [ ] closes #xxxx
- [x] tests added / passed
- [x] passes `black pandas`
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry


Labels:
name: Error Reporting
description: Incorrect or improved errors from pandas
name: Timezones
description: Timezone data dtype

Comments:
i guess this is a small api change (e.g. what did this do before)?

can you add a whatsnew note (rebase as well)
@jbrockmendel what's the rationale of requiring matching timezone here? (as long as tz-awareness matches)
> what's the rationale of requiring matching timezone here? (as long as tz-awareness matches)

Trying to have some consistency about which methods require matching tz vs just tzawareness-compat.  The heuristic is to require matching tz for setitem-like methods.

Isn't that inconsisten with other operations like aritmetic/comparison ops, which allow it? (like the subtract PR that is also open) 

Also setitem on Series doesn't actually raise, so on the Series level, those methods are also not fully consistent.
> Isn't that inconsisten with other operations like aritmetic/comparison ops, which allow it? (like the subtract PR that is also open)

Right, those methods are not considered "setitem-like".  searchsorted is also considered comparison-like as opposed to setitem-like.

> Also setitem on Series doesn't actually raise, so on the Series level, those methods are also not fully consistent.

The Series is cast to object and the value being set is not cast to the existing timezone.  DatetimeBlock._can_hold_element is equivalent to

```
def _can_hold_element(self, element):
    try:
        self.array_values()._validate_setitem_value(element)
        return True
    except TypeError:
        return False
```
> > Isn't that inconsisten with other operations like aritmetic/comparison ops, which allow it? (like the subtract PR that is also open)
> 
> Right, those methods are not considered "setitem-like". searchsorted is also considered comparison-like as opposed to setitem-like.
> 
> > Also setitem on Series doesn't actually raise, so on the Series level, those methods are also not fully consistent.
> 
> The Series is cast to object and the value being set is not cast to the existing timezone. DatetimeBlock._can_hold_element is equivalent to
> 
> ```
> def _can_hold_element(self, element):
>     try:
>         self.array_values()._validate_setitem_value(element)
>         return True
>     except TypeError:
>         return False
> ```

we should rationalize these one way or the other for all ops. I would be +1 on always being strict here, though this would break some existing code / tests.
> we should rationalize these one way or the other for all ops. I would be +1 on always being strict here, though this would break some existing code / tests.

I'd be on board with being consistent across all these methods, but I think we would basically _have_ to make it the non-strict version.  Otherwise we would break consistency with the stdlib datetime on comparisons (xref #37329).

thanks @jbrockmendel 

yeah I agree we need to make this consitent, but this PR itself is fine as its just requires a tz matching fill value.