Skip to content

Commit 89e62c0

Browse files
committed
Merge pull request #3878 from cpcloud/index-join-date-casting-fix-3877
ENH: do not convert mixed-integer type indexes to datetimeindex
2 parents b204e14 + bd811dc commit 89e62c0

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

RELEASE.rst

+3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ pandas 0.11.1
8080
- Added Faq section on repr display options, to help users customize their setup.
8181
- ``where`` operations that result in block splitting are much faster (GH3733_)
8282
- Series and DataFrame hist methods now take a ``figsize`` argument (GH3834_)
83+
- DatetimeIndexes no longer try to convert mixed-integer indexes during join
84+
operations (GH3877_)
8385

8486
**API Changes**
8587

@@ -317,6 +319,7 @@ pandas 0.11.1
317319
.. _GH3814: https://github.com/pydata/pandas/issues/3814
318320
.. _GH3834: https://github.com/pydata/pandas/issues/3834
319321
.. _GH3873: https://github.com/pydata/pandas/issues/3873
322+
.. _GH3877: https://github.com/pydata/pandas/issues/3877
320323

321324

322325
pandas 0.11.0

doc/source/v0.11.1.txt

+3
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ Enhancements
289289
dff.groupby('B').filter(lambda x: len(x) > 2, dropna=False)
290290

291291
- Series and DataFrame hist methods now take a ``figsize`` argument (GH3834_)
292+
- DatetimeIndexes no longer try to convert mixed-integer indexes during join
293+
operations (GH3877_)
292294

293295

294296
Bug Fixes
@@ -402,3 +404,4 @@ on GitHub for a complete list.
402404
.. _GH3425: https://github.com/pydata/pandas/issues/3425
403405
.. _GH3834: https://github.com/pydata/pandas/issues/3834
404406
.. _GH3873: https://github.com/pydata/pandas/issues/3873
407+
.. _GH3877: https://github.com/pydata/pandas/issues/3877

pandas/tseries/index.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,8 @@ def join(self, other, how='left', level=None, return_indexers=False):
910910
"""
911911
See Index.join
912912
"""
913-
if not isinstance(other, DatetimeIndex) and len(other) > 0:
913+
if (not isinstance(other, DatetimeIndex) and len(other) > 0 and
914+
other.inferred_type != 'mixed-integer'):
914915
try:
915916
other = DatetimeIndex(other)
916917
except TypeError:

pandas/tseries/tests/test_timeseries.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import pandas.core.datetools as datetools
1919
import pandas.tseries.offsets as offsets
2020
import pandas.tseries.frequencies as fmod
21-
from pandas.tseries.index import TimeSeriesError
2221
import pandas as pd
2322

2423
from pandas.util.testing import assert_series_equal, assert_almost_equal
@@ -1853,6 +1852,14 @@ def test_date(self):
18531852
expected = [t.date() for t in rng]
18541853
self.assert_((result == expected).all())
18551854

1855+
def test_does_not_convert_mixed_integer(self):
1856+
df = tm.makeCustomDataframe(10, 10, data_gen_f=lambda *args, **kwargs:
1857+
randn(), r_idx_type='i', c_idx_type='dt')
1858+
cols = df.columns.join(df.index, how='outer')
1859+
joined = cols.join(df.columns)
1860+
self.assertEqual(cols.dtype, np.dtype('O'))
1861+
self.assertEqual(cols.dtype, joined.dtype)
1862+
self.assert_(np.array_equal(cols.values, joined.values))
18561863

18571864
class TestLegacySupport(unittest.TestCase):
18581865
_multiprocess_can_split_ = True

0 commit comments

Comments
 (0)