You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Concatenating a DataFrame containing NaT with a tz specified with another DataFrame containing an actual date with tz specified results in an object dtype instead of the expected datetime64[ns, UTC] dtype.
Output of pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.6.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 158 Stepping 9, GenuineIntel
byteorder: little
LC_ALL: None
LANG: en
LOCALE: None.None
I think the issue is in the DataFrame constructor?
In [48]: df1.dtypesOut[48]:
0datetime64[ns]
dtype: object
That said, there's no way for the constructor to infer datetime64[ns, UTC] as the correct dtype. You would need df1 = pd.DataFrame([[ts1]], dtype='datetime64[ns, UTC]')
When concating two different dataframes with different timezone information (in this case None and UTC, we aim to preserve the timezone information on both sides so the object type is expected. One can use to_datetime to get back a datetime64[ns, UTC] dtype after the operation
Code Sample, a copy-pastable example if possible
Problem description
Concatenating a DataFrame containing NaT with a tz specified with another DataFrame containing an actual date with tz specified results in an object dtype instead of the expected datetime64[ns, UTC] dtype.
Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.6.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 158 Stepping 9, GenuineIntel
byteorder: little
LC_ALL: None
LANG: en
LOCALE: None.None
pandas: 0.24.0.dev0+708.gce1f81f8b
pytest: 3.8.2
pip: 10.0.1
setuptools: 40.2.0
Cython: 0.28.5
numpy: 1.15.2
scipy: 1.1.0
pyarrow: None
xarray: 0.10.9
IPython: 6.5.0
sphinx: 1.8.1
patsy: 0.5.0
dateutil: 2.7.3
pytz: 2018.5
blosc: None
bottleneck: 1.2.1
tables: 3.4.4
numexpr: 2.6.8
feather: None
matplotlib: 3.0.0
openpyxl: 2.5.5
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 1.1.1
lxml: 4.2.5
bs4: 4.6.3
html5lib: 1.0.1
sqlalchemy: 1.2.12
pymysql: 0.9.2
psycopg2: None
jinja2: 2.10
s3fs: 0.1.6
fastparquet: 0.1.6
pandas_gbq: None
pandas_datareader: None
gcsfs: 0.1.2
The text was updated successfully, but these errors were encountered: