Concat of tz-aware and tz-unaware dataframes fails · Issue #12467 · pandas-dev/pandas (original) (raw)

This snippet

import pandas as pd df1 = pd.DataFrame(dict(time=[pd.Timestamp('2015-01-01', tz=None)])) df2 = pd.DataFrame(dict(time=[pd.Timestamp('2015-01-01', tz='UTC')])) pd.concat([df1, df2])

causes

.../pandas/tseries/common.py in _concat_compat(to_concat, axis)
282 if 'datetime' in typs or 'object' in typs:
283 to_concat = [convert_to_pydatetime(x, axis) for x in to_concat]
--> 284 return np.concatenate(to_concat, axis=axis)
285
286 # we require ALL of the same tz for datetimetz

ValueError: all the input arrays must have same number of dimensions

We would expect it to return something like this

pd.DataFrame(dict(time=pd.Series([pd.Timestamp('2015-01-01', tz=None), pd.Timestamp('2015-01-01', tz='UTC')], dtype=object)))
Out[18]:
time
0 2015-01-01 00:00:00
1 2015-01-01 00:00:00+00:00

output of pd.show_versions()

INSTALLED VERSIONS

commit: fe584e7
python: 2.7.11.final.0
python-bits: 64
OS: Linux
OS-release: 3.13.0-53-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.18.0rc1+47.gfe584e7
nose: 1.3.7
pip: 8.0.3
setuptools: 20.1.1
Cython: 0.23.4
numpy: 1.10.4
scipy: None
statsmodels: None
xarray: None
IPython: 4.1.1
sphinx: 1.3.5
patsy: None
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 0.9.4
sqlalchemy: 0.9.4
pymysql: None
psycopg2: None
jinja2: 2.8