BUG: tz-aware datetime with column-wise comparisions failing with np.minmum/maximum #15552
Code Sample, a copy-pastable example if possible
>>> import numpy as np >>> import pandas as pd >>> naive = pd.to_datetime(['now']) >>> utc = naive.tz_localize('UTC') >>> np.minimum(naive, naive) >>> np.minimum(utc, utc) >>> np.minimum(pd.Series(naive), pd.Series(naive)) >>> np.minimum(pd.Series(utc), pd.Series(utc)) File "bug.py", line 10, in <module> np.minimum(pd.Series(utc), pd.Series(utc)) File "~/anaconda3/lib/python3.5/site-packages/pandas/core/series.py", line 498, in __array_prepare__ op=context.__name__)) TypeError: Series with dtype datetime64[ns, UTC] cannot perform the numpy op minimum
When a tz-aware datetime is placed in a
this is related to this: #15553
but that said, there is only so much that can be done when passing things directly to numpy arrays like this (its actually not the passing, but returning, some numpy functions are friendly and some are not).
I suppose this could be made to work, below is a much more idiomatic way to do this. See the 2nd part for the actual issue.
doesn't raise, but incorrect results for tz-aware
this is not true at all, they naively look like they are working, but because of the same issue above (numpy has no clue about timezones, and forget about missing values), these are completely wrong (they are tz shifted incorrectly)