BUG-22796 Concat multicolumn tz-aware DataFrame
State: closed

- [X] closes #22796 
- [X] tests added / passed
- [X] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [X] whatsnew entry

Numpy arrays don't have the datetimetz dtype, so I just passed through the DatetimeIndex directly.

Side note: There's another small bug (I think) where np.nan or pd.NaT takes on the dtype of the column instead of the row when concatenating, but the column should instead have an object dtype.


Labels:
name: Reshaping
description: Concat, Merge/Join, Stack/Unstack, Explode
name: Timezones
description: Timezone data dtype

Comments:
Hello @tonytao2012! Thanks for updating the PR.

 - There are no PEP8 issues in the file [`pandas/core/dtypes/dtypes.py`](https://github.com/tonytao2012/pandas/blob/a0570bdadf5cdec2ca7c75c87f997c48869e3336/pandas/core/dtypes/dtypes.py) !

 - There are no PEP8 issues in the file [`pandas/core/internals/concat.py`](https://github.com/tonytao2012/pandas/blob/a0570bdadf5cdec2ca7c75c87f997c48869e3336/pandas/core/internals/concat.py) !

 - There are no PEP8 issues in the file [`pandas/tests/frame/test_combine_concat.py`](https://github.com/tonytao2012/pandas/blob/a0570bdadf5cdec2ca7c75c87f997c48869e3336/pandas/tests/frame/test_combine_concat.py) !



##### Comment last updated on October 09, 2018 at 12:08 Hours UTC
The bug you're describing may be https://github.com/pandas-dev/pandas/issues/12499
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23036?src=pr&el=h1) Report
> Merging [#23036](https://codecov.io/gh/pandas-dev/pandas/pull/23036?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/ca7d518cba8e1c6ed96328fed8968afb23588077?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/23036/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/23036?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #23036      +/-   ##
==========================================
- Coverage   92.19%   92.19%   -0.01%     
==========================================
  Files         169      169              
  Lines       50904    50911       +7     
==========================================
+ Hits        46933    46939       +6     
- Misses       3971     3972       +1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.61% <100%> (-0.01%)` | :arrow_down: |
| #single | `42.3% <14.28%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/23036?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/internals/concat.py](https://codecov.io/gh/pandas-dev/pandas/pull/23036/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL2NvbmNhdC5weQ==) | `98% <100%> (-0.38%)` | :arrow_down: |
| [pandas/core/dtypes/dtypes.py](https://codecov.io/gh/pandas-dev/pandas/pull/23036/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2R0eXBlcy5weQ==) | `95.58% <100%> (+0.03%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23036?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23036?src=pr&el=footer). Last update [ca7d518...de4c427](https://codecov.io/gh/pandas-dev/pandas/pull/23036?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Added the xfail test and linked to issue #23037. Thanks for the feedback.
Just to make sure, on this PR I get

```python
In [1]: import pandas as pd

In [2]: a = pd.DataFrame({"A": pd.to_datetime([1, 2]).tz_localize("UTC")})

In [3]: b = pd.DataFrame({"A": pd.to_datetime([1, 2]).tz_localize("UTC"), "B": pd.to_datetime([1, 2]).tz_localize("UTC")})

In [4]: pd.concat([a, b], sort=True).B.values
Out[4]:
array([                          'NaT', '1970-01-01T00:00:00.000000001',
       '1970-01-01T00:00:00.000000002'], dtype='datetime64[ns]')

In [5]: pd.concat([a, b], sort=True)
Out[5]:
                                    A                                   B
0 1970-01-01 00:00:00.000000001+00:00                                 NaT
1 1970-01-01 00:00:00.000000002+00:00 1970-01-01 00:00:00.000000001+00:00
0 1970-01-01 00:00:00.000000001+00:00 1970-01-01 00:00:00.000000002+00:00
1 1970-01-01 00:00:00.000000002+00:00
```

the xfail you added @jreback is for the fact that `B` in `Out[5]` is incorrect?
hmm, that does look suspicious but that's not the reason for the xfail.
pushed an updated, that was a just-introduced bug.
one more time to fix the lint issue.
thanks @tonytao2012 

welcome to have you work on the issue that we are xfailing