BUG: Fix+test dataframe tranpose with datetimeTZ
State: closed

Reminder of the bug here:

```
>>> dti = pd.date_range('1977-04-15', periods=3, freq='MS', tz='US/Hawaii')
>>> df = pd.DataFrame(dti)
>>> df.T
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pandas/core/frame.py", line 2562, in transpose
    return super(DataFrame, self).transpose(1, 0, **kwargs)
  File "pandas/core/generic.py", line 686, in transpose
    new_values = self.values.transpose(axes_numbers)
  File "pandas/core/base.py", line 672, in transpose
    nv.validate_transpose(args, kwargs)
  File "pandas/compat/numpy/function.py", line 56, in __call__
    self.defaults)
  File "pandas/util/_validators.py", line 218, in validate_args_and_kwargs
    validate_kwargs(fname, kwargs, compat_args)
  File "pandas/util/_validators.py", line 157, in validate_kwargs
    _check_for_default_values(fname, kwds, compat_args)
  File "pandas/util/_validators.py", line 69, in _check_for_default_values
    format(fname=fname, arg=key)))
ValueError: the 'axes' parameter is not supported in the pandas implementation of transpose()
```

The implementation is an unholy mess.  It can be made a little bit prettier, but to actually get a nice implementation we need to allow 2D EAs.

Labels:
name: Bug
name: Datetime
description: Datetime data dtype

Comments:
Hello @jbrockmendel! Thanks for submitting the PR.

 - There are no PEP8 issues in the file [`pandas/core/generic.py`](https://github.com/jbrockmendel/pandas/blob/24d67830b4421663601d43c8448fc919d2080529/pandas/core/generic.py) !

 - There are no PEP8 issues in the file [`pandas/core/internals/managers.py`](https://github.com/jbrockmendel/pandas/blob/24d67830b4421663601d43c8448fc919d2080529/pandas/core/internals/managers.py) !

 - There are no PEP8 issues in the file [`pandas/tests/arithmetic/conftest.py`](https://github.com/jbrockmendel/pandas/blob/24d67830b4421663601d43c8448fc919d2080529/pandas/tests/arithmetic/conftest.py) !

 - There are no PEP8 issues in the file [`pandas/tests/arithmetic/test_datetime64.py`](https://github.com/jbrockmendel/pandas/blob/24d67830b4421663601d43c8448fc919d2080529/pandas/tests/arithmetic/test_datetime64.py) !

 - There are no PEP8 issues in the file [`pandas/tests/arithmetic/test_timedelta64.py`](https://github.com/jbrockmendel/pandas/blob/24d67830b4421663601d43c8448fc919d2080529/pandas/tests/arithmetic/test_timedelta64.py) !

 - There are no PEP8 issues in the file [`pandas/tests/frame/test_reshape.py`](https://github.com/jbrockmendel/pandas/blob/24d67830b4421663601d43c8448fc919d2080529/pandas/tests/frame/test_reshape.py) !


# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23730?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@2af56d4`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff            @@
##             master   #23730   +/-   ##
=========================================
  Coverage          ?   92.29%           
=========================================
  Files             ?      161           
  Lines             ?    51478           
  Branches          ?        0           
=========================================
  Hits              ?    47511           
  Misses            ?     3967           
  Partials          ?        0
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.68% <100%> (?)` | |
| #single | `42.31% <74.07%> (?)` | |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/23730?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/internals/managers.py](https://codecov.io/gh/pandas-dev/pandas/pull/23730/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL21hbmFnZXJzLnB5) | `95.74% <100%> (ø)` | |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/23730/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.02% <100%> (ø)` | |
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/23730/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `96.87% <100%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23730?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/23730?src=pr&el=footer). Last update [2af56d4...0f38a69](https://codecov.io/gh/pandas-dev/pandas/pull/23730?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Updated to be a little prettier, but still fundamentally a kludge.

@TomAugspurger @jorisvandenbossche thoughts on this?  I maintain the non-kludge way to fix this is to allow 2D DatetimeArray.

Also, will need its own issue, but adding to the "let's not layer on more kludges" pile:

```
>>> ts = pd.Timestamp.now().tz_localize('US/Pacific')
>>> data = np.array([[ts, ts, ts], [ts, ts, ts]])
>>> pd.DataFrame(data)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pandas/core/frame.py", line 416, in __init__
    copy=copy)
  File "pandas/core/frame.py", line 574, in _init_ndarray
    return create_block_manager_from_blocks([values], [columns, index])
  File "pandas/core/internals/managers.py", line 1665, in create_block_manager_from_blocks
    mgr = BlockManager(blocks, axes)
  File "pandas/core/internals/managers.py", line 118, in __init__
    self=self.ndim))
AssertionError: Number of Block dimensions (1) must equal number of axes (2)
```
@jbrockmendel I would rather you set this while transpose bizness aside. This needs to be pushed into internals, and does not need EA 2-D support to make this work. This kludge won't be accepted in its current form. Much rather get datetime EA fnished. This is not neceessary for that.
Will look closely later, but I think the transpose stuff will be handled automatically by internals when DatetimeArray is an extension array.
Travis fail is the test_rank segfault.

An argument against 2D DatetimeArray: `freq` wouldn't make much sense.

When other things clear up I'll take a look at pushing this into internals.  This bug is high on my list of pet peeves at the moment, so I'm not likely to let it go.
@jbrockmendel I would put this aside. This is just a hack and not worth the time / effort right now. Lots more fish to fry. This 'bug' has existed for quite a long time, and to be honest this is just a not-that interesting edge case.
Closing as not actionable.