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

Concatenating two localized datetimes returns NaTs #12217

Closed
andyljones opened this issue Feb 3, 2016 · 2 comments
Closed

Concatenating two localized datetimes returns NaTs #12217

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

Comments

@andyljones
Copy link

Issue:

import pandas as pd
from datetime import datetime

### Concat'ing two UTC times works
first = pd.DataFrame([[datetime(2016, 1, 1)]])
first[0] = first[0].dt.tz_localize('UTC')

second = pd.DataFrame([[datetime(2016, 1, 2)]])
second[0] = second[0].dt.tz_localize('UTC')

print pd.concat([first, second]) # Works


### Concat'ing two London times doesn't work
first = pd.DataFrame([[datetime(2016, 1, 1)]])
first[0] = first[0].dt.tz_localize('Europe/London')

second = pd.DataFrame([[datetime(2016, 1, 2)]])
second[0] = second[0].dt.tz_localize('Europe/London')

print pd.concat([first, second]) # Doesn't work - returns a DF full of NaTs


### Concat'ing 2+1 London times works
first = pd.DataFrame([[datetime(2016, 1, 1)], [datetime(2016, 1, 2)]])
first[0] = first[0].dt.tz_localize('Europe/London')

second = pd.DataFrame([[datetime(2016, 1, 3)]])
second[0] = second[0].dt.tz_localize('Europe/London')

print pd.concat([first, second]) # Works


### Concat'ing 1+2 London times doesn't work
first = pd.DataFrame([[datetime(2016, 1, 1)]])
first[0] = first[0].dt.tz_localize('Europe/London')

second = pd.DataFrame([[datetime(2016, 1, 2)], [datetime(2016, 1, 3)]])
second[0] = second[0].dt.tz_localize('Europe/London')

print pd.concat([first, second]) # Doesn't work - first row is NaT

Dependencies:

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Linux
OS-release: 3.17.7-300.fc21.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8

pandas: 0.17.1
nose: None
pip: 8.0.2
setuptools: 19.4
Cython: None
numpy: 1.10.2
scipy: 0.16.0
statsmodels: None
IPython: 4.0.1
sphinx: 1.3.1
patsy: None
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: None
tables: None
numexpr: 2.4.4
matplotlib: 1.5.0
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: 3.5.0
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
Jinja2: None
@pag
Copy link

pag commented Feb 3, 2016

I can replicate with python 2.7.10, windows 10, pandas 0.17.1, numpy 1.9.3.

@jreback
Copy link
Contributor

jreback commented Feb 3, 2016

hmm, partially was addressed in #12195

but still looks buggy

@jreback jreback added Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode Timezones Timezone data dtype Difficulty Intermediate labels Feb 3, 2016
@jreback jreback added this to the Next Major Release milestone Feb 3, 2016
@jreback jreback modified the milestones: 0.18.0, Next Major Release Feb 12, 2016
jreback added a commit to jreback/pandas that referenced this issue Feb 12, 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

Successfully merging a pull request may close this issue.

3 participants