{"action":"created","issue":{"url":"https://api.github.com/repos/pydata/pandas/issues/14052","repository_url":"https://api.github.com/repos/pydata/pandas","labels_url":"https://api.github.com/repos/pydata/pandas/issues/14052/labels{/name}","comments_url":"https://api.github.com/repos/pydata/pandas/issues/14052/comments","events_url":"https://api.github.com/repos/pydata/pandas/issues/14052/events","html_url":"https://github.com/pydata/pandas/issues/14052","id":172272637,"number":14052,"title":"SingleBlockManager.is_mixed_type does not handle properly datetime64[ns,UTC]","user":{"login":"sdementen","id":1304950,"avatar_url":"https://avatars.githubusercontent.com/u/1304950?v=3","gravatar_id":"","url":"https://api.github.com/users/sdementen","html_url":"https://github.com/sdementen","followers_url":"https://api.github.com/users/sdementen/followers","following_url":"https://api.github.com/users/sdementen/following{/other_user}","gists_url":"https://api.github.com/users/sdementen/gists{/gist_id}","starred_url":"https://api.github.com/users/sdementen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdementen/subscriptions","organizations_url":"https://api.github.com/users/sdementen/orgs","repos_url":"https://api.github.com/users/sdementen/repos","events_url":"https://api.github.com/users/sdementen/events{/privacy}","received_events_url":"https://api.github.com/users/sdementen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-20T14:05:04Z","updated_at":"2016-08-24T23:20:52Z","closed_at":null,"body":"When getting the values of a dataframe with multiple columns with a single type datetime64[ns,UTC], it returns a numpy array with dtype=object instead of dtype=datetime64[ns,UTC].\r\nWhen returning a single column with dtype=datetime64[ns,UTC] or returning a multiple columns of dtype=datetime64\\[ns] (ie without tz), it works.\r\nLooking at the code, it appears that SingleBlockManager.is_mixed_type returns False in the first case (datetime64[ns,UTC]) and True in the two other cases (single datetime64[ns,UTC] or multiple datetime64[ns]).\r\n\r\n#### Code Sample, a copy-pastable example if possible\r\n```\r\nimport pandas\r\n\r\nidx = pandas.date_range(\"2010\", \"2011\", tz=\"UTC\")\r\ndf = pandas.DataFrame(index=idx)\r\ndf[\"A\"] = idx\r\ndf[\"B\"] = idx\r\nprint(df[[\"B\"]].values.dtype)\r\nprint(df[[\"A\", \"B\"]].values.dtype)\r\n```\r\n#### Actual Output\r\n```\r\ndatetime64[ns, UTC]\r\nobject\r\n```\r\n#### Expected Output\r\n```\r\ndatetime64[ns, UTC]\r\ndatetime64[ns, UTC]\r\n```\r\n#### output of ``pd.show_versions()``\r\nINSTALLED VERSIONS\r\n\r\ncommit: None\r\npython: 3.5.2.final.0\r\npython-bits: 32\r\nOS: Windows\r\nOS-release: 7\r\nmachine: AMD64\r\nprocessor: Intel64 Family 6 Model 61 Stepping 4, GenuineIntel\r\nbyteorder: little\r\nLC_ALL: None\r\nLANG: None\r\n\r\npandas: 0.18.1\r\nnose: None\r\npip: 8.1.2\r\nsetuptools: 23.0.0\r\nCython: None\r\nnumpy: 1.11.0\r\nscipy: 0.17.1\r\nstatsmodels: None\r\nxarray: None\r\nIPython: 4.2.0\r\nsphinx: None\r\npatsy: None\r\ndateutil: 2.5.3\r\npytz: 2016.4\r\nblosc: None\r\nbottleneck: None\r\ntables: None\r\nnumexpr: 2.6.1\r\nmatplotlib: 1.5.1\r\nopenpyxl: 2.3.2\r\nxlrd: 1.0.0\r\nxlwt: None\r\nxlsxwriter: 0.9.2\r\nlxml: 3.6.0\r\nbs4: None\r\nhtml5lib: None\r\nhttplib2: 0.9.2\r\napiclient: None\r\nsqlalchemy: 1.0.12\r\npymysql: None\r\npsycopg2: 2.6.2 (dt dec pq3 ext)\r\njinja2: 2.8\r\nboto: None\r\npandas_datareader: None"},"comment":{"url":"https://api.github.com/repos/pydata/pandas/issues/comments/242238205","html_url":"https://github.com/pydata/pandas/issues/14052#issuecomment-242238205","issue_url":"https://api.github.com/repos/pydata/pandas/issues/14052","id":242238205,"user":{"login":"jreback","id":953992,"avatar_url":"https://avatars.githubusercontent.com/u/953992?v=3","gravatar_id":"","url":"https://api.github.com/users/jreback","html_url":"https://github.com/jreback","followers_url":"https://api.github.com/users/jreback/followers","following_url":"https://api.github.com/users/jreback/following{/other_user}","gists_url":"https://api.github.com/users/jreback/gists{/gist_id}","starred_url":"https://api.github.com/users/jreback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jreback/subscriptions","organizations_url":"https://api.github.com/users/jreback/orgs","repos_url":"https://api.github.com/users/jreback/repos","events_url":"https://api.github.com/users/jreback/events{/privacy}","received_events_url":"https://api.github.com/users/jreback/received_events","type":"User","site_admin":false},"created_at":"2016-08-24T23:20:52Z","updated_at":"2016-08-24T23:20:52Z","body":"No, this is correct. When you so ``.values`` on a ``DataFrame``, you get an object which can hold all of the data. This almost always is a ``numpy-array``, which is ``object`` type when it cannot hold the data-type directly (as it is for *multiple* tz-aware columns, EVEN IF THEY ARE THE SAME tz). However for a single column, we return the underlying data, which is implemented with a ``DatetimeIndex``. I suppose this is a bit inconsistent, but is not likely to change in the current implementation of pandas (in pandas 2.0 things will be more consistent).\r\n\r\n```\r\nIn [88]: df[['A','B']].dtypes\r\nOut[88]: \r\nA    datetime64[ns, UTC]\r\nB    datetime64[ns, UTC]\r\ndtype: object\r\n```\r\n\r\nHere you are getting the actual type\r\n```\r\nIn [90]: df[['A']].values\r\nOut[90]: \r\nDatetimeIndex(['2010-01-01', '2010-01-02', '2010-01-03', '2010-01-04', '2010-01-05', '2010-01-06', '2010-01-07', '2010-01-08', '2010-01-09', '2010-01-10',\r\n               ...\r\n               '2010-12-23', '2010-12-24', '2010-12-25', '2010-12-26', '2010-12-27', '2010-12-28', '2010-12-29', '2010-12-30', '2010-12-31', '2011-01-01'],\r\n              dtype='datetime64[ns, UTC]', length=366, freq='D')\r\n\r\n# this is a combination of the SAME tz-aware series as object dtype\r\nIn [91]: df[['A', 'B']].values\r\nOut[91]: \r\narray([[Timestamp('2010-01-01 00:00:00+0000', tz='UTC'),\r\n        Timestamp('2010-01-01 00:00:00+0000', tz='UTC')],\r\n       [Timestamp('2010-01-02 00:00:00+0000', tz='UTC'),\r\n        Timestamp('2010-01-02 00:00:00+0000', tz='UTC')],\r\n       [Timestamp('2010-01-03 00:00:00+0000', tz='UTC'),\r\n        Timestamp('2010-01-03 00:00:00+0000', tz='UTC')],\r\n       [Timestamp('2010-01-04 00:00:00+0000', tz='UTC'),\r\n        Timestamp('2010-01-04 00:00:00+0000', tz='UTC')],\r\n       [Timestamp('2010-01-05 00:00:00+0000', tz='UTC'),\r\n        Timestamp('2010-01-05 00:00:00+0000', tz='UTC')],\r\n       [Timestamp('2010-01-06 00:00:00+0000', tz='UTC'),\r\n        Timestamp('2010-01-06 00:00:00+0000', tz='UTC')],\r\n       [Timestamp('2010-01-07 00:00:00+0000', tz='UTC'),\r\n        Timestamp('2010-01-07 00:00:00+0000', tz='UTC')],\r\n       [Timestamp('2010-01-08 00:00:00+0000', tz='UTC'),\r\n....\r\n```\r\n\r\n"}}
{"actor":{"display_login":"jreback"}}