|
20 | 20 | is_numeric_dtype,
|
21 | 21 | is_datetime64_dtype,
|
22 | 22 | is_timedelta64_dtype,
|
| 23 | + is_datetime64tz_dtype, |
23 | 24 | is_list_like,
|
24 | 25 | is_dict_like,
|
25 | 26 | is_re_compilable)
|
@@ -4438,13 +4439,23 @@ def _align_frame(self, other, join='outer', axis=None, level=None,
|
4438 | 4439 | left = left.fillna(axis=fill_axis, method=method, limit=limit)
|
4439 | 4440 | right = right.fillna(axis=fill_axis, method=method, limit=limit)
|
4440 | 4441 |
|
| 4442 | + # if DatetimeIndex have different tz, convert to UTC |
| 4443 | + if is_datetime64tz_dtype(left.index): |
| 4444 | + if left.index.tz != right.index.tz: |
| 4445 | + if join_index is not None: |
| 4446 | + left.index = join_index |
| 4447 | + right.index = join_index |
| 4448 | + |
4441 | 4449 | return left.__finalize__(self), right.__finalize__(other)
|
4442 | 4450 |
|
4443 | 4451 | def _align_series(self, other, join='outer', axis=None, level=None,
|
4444 | 4452 | copy=True, fill_value=None, method=None, limit=None,
|
4445 | 4453 | fill_axis=0):
|
| 4454 | + |
| 4455 | + is_series = isinstance(self, ABCSeries) |
| 4456 | + |
4446 | 4457 | # series/series compat, other must always be a Series
|
4447 |
| - if isinstance(self, ABCSeries): |
| 4458 | + if is_series: |
4448 | 4459 | if axis:
|
4449 | 4460 | raise ValueError('cannot align series to a series other than '
|
4450 | 4461 | 'axis 0')
|
@@ -4503,6 +4514,15 @@ def _align_series(self, other, join='outer', axis=None, level=None,
|
4503 | 4514 | left = left.fillna(fill_value, method=method, limit=limit,
|
4504 | 4515 | axis=fill_axis)
|
4505 | 4516 | right = right.fillna(fill_value, method=method, limit=limit)
|
| 4517 | + |
| 4518 | + # if DatetimeIndex have different tz, convert to UTC |
| 4519 | + if is_series or (not is_series and axis == 0): |
| 4520 | + if is_datetime64tz_dtype(left.index): |
| 4521 | + if left.index.tz != right.index.tz: |
| 4522 | + if join_index is not None: |
| 4523 | + left.index = join_index |
| 4524 | + right.index = join_index |
| 4525 | + |
4506 | 4526 | return left.__finalize__(self), right.__finalize__(other)
|
4507 | 4527 |
|
4508 | 4528 | def _where(self, cond, other=np.nan, inplace=False, axis=None, level=None,
|
|
0 commit comments