diff --git a/doc/source/contributing.rst b/doc/source/contributing.rst index 9ba4915d235ee..c26fd8255df53 100644 --- a/doc/source/contributing.rst +++ b/doc/source/contributing.rst @@ -219,7 +219,8 @@ For Python 2.7, you can install the ``mingw`` compiler which will work equivalen or use the `Microsoft Visual Studio VC++ compiler for Python `__. Note that you have to check the ``x64`` box to install the ``x64`` extension building capability as this is not installed by default. -For Python 3.4, you can download and install the `Windows 7.1 SDK `__ +For Python 3.4, you can download and install the `Windows 7.1 SDK `__. Read the references below as there may be various gotchas during the installation. + For Python 3.5, you can download and install the `Visual Studio 2015 Community Edition `__. Here are some references: diff --git a/pandas/tests/series/test_analytics.py b/pandas/tests/series/test_analytics.py index 455e5cda03307..6c3df944637f9 100644 --- a/pandas/tests/series/test_analytics.py +++ b/pandas/tests/series/test_analytics.py @@ -160,6 +160,13 @@ def test_mode(self): assert_series_equal(s.mode(), Series(['2011-01-03', '2013-01-02'], dtype='M8[ns]')) + # GH 5986 + s = Series(['1 days', '-1 days', '0 days'], dtype='timedelta64[ns]') + assert_series_equal(s.mode(), Series([], dtype='timedelta64[ns]')) + + s = Series(['1 day', '1 day', '-1 day', '-1 day 2 min', '2 min', '2 min'], dtype='timedelta64[ns]') + assert_series_equal(s.mode(), Series(['2 min', '1 day'], dtype='timedelta64[ns]')) + def test_prod(self): self._check_stat_op('prod', np.prod) @@ -1015,6 +1022,12 @@ def test_rank(self): iranks = iseries.rank() assert_series_equal(iranks, exp) + # GH 5968 + iseries = Series([1e-50, 1e-100, 1e-20, 1e-2, 1e-20 + 1e-30, 1e-1, pd.NaT], dtype='timedelta64[ns]') + exp = Series([2, 1, 3, 5, 4, 6, 7]) + iranks = iseries.rank() + assert_series_equal(iranks, exp) + values = np.array( [-50, -1, -1e-20, -1e-25, -1e-50, 0, 1e-40, 1e-20, 1e-10, 2, 40 ], dtype='float64') diff --git a/pandas/tests/test_algos.py b/pandas/tests/test_algos.py index ef3f6210f0c21..380e0a581e781 100644 --- a/pandas/tests/test_algos.py +++ b/pandas/tests/test_algos.py @@ -143,6 +143,20 @@ def test_datelike(self): [0, 0, 0, 1, 1, 0], dtype=np.int64)) self.assert_numpy_array_equal(uniques, pd.PeriodIndex([v1, v2])) + # GH 5986 + v1 = pd.to_timedelta('1 day 1 min') + v2 = pd.to_timedelta('1 day') + x = Series([v1, v2, v1, v1, v2, v2, v1]) + labels, uniques = algos.factorize(x) + self.assert_numpy_array_equal(labels, np.array( + [0, 1, 0, 0, 1, 1, 0], dtype=np.int64)) + self.assert_numpy_array_equal(uniques, pd.to_timedelta([v1, v2])) + + labels, uniques = algos.factorize(x, sort=True) + self.assert_numpy_array_equal(labels, np.array( + [1, 0, 1, 1, 0, 0, 1], dtype=np.int64)) + self.assert_numpy_array_equal(uniques, pd.to_timedelta([v2, v1])) + def test_factorize_nan(self): # nan should map to na_sentinel, not reverse_indexer[na_sentinel] # rizer.factorize should not raise an exception if na_sentinel indexes