Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concat of tz-aware and tz-unaware dataframes fails #12467

Closed
tsdlovell opened this issue Feb 26, 2016 · 2 comments
Closed

Concat of tz-aware and tz-unaware dataframes fails #12467

tsdlovell opened this issue Feb 26, 2016 · 2 comments
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode Timezones Timezone data dtype
Milestone

Comments

@tsdlovell
Copy link
Contributor

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

@jreback jreback added Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode Timezones Timezone data dtype labels Feb 27, 2016
@jreback jreback modified the milestones: 0.18.0, 0.18.1 Feb 27, 2016
@jreback
Copy link
Contributor

jreback commented Mar 23, 2016

can you rebase/update

@tsdlovell
Copy link
Contributor Author

rebased, looking into the test failures

@jreback jreback closed this as completed in e04f343 Apr 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode Timezones Timezone data dtype
Projects
None yet
Development

No branches or pull requests

2 participants