Skip to content

Commit 7d1499c

Browse files
Da Wangjreback
Da Wang
authored andcommitted
BUG: Add mode, rank and factorize tests for #5986 (unique, quantile and value_counts tests already exist)
closes #5986 closes #12465 DOC: emphasize reference in windows installation
1 parent 78d671f commit 7d1499c

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

doc/source/contributing.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ For Python 2.7, you can install the ``mingw`` compiler which will work equivalen
219219

220220
or use the `Microsoft Visual Studio VC++ compiler for Python <https://www.microsoft.com/en-us/download/details.aspx?id=44266>`__. Note that you have to check the ``x64`` box to install the ``x64`` extension building capability as this is not installed by default.
221221

222-
For Python 3.4, you can download and install the `Windows 7.1 SDK <https://www.microsoft.com/en-us/download/details.aspx?id=8279>`__
222+
For Python 3.4, you can download and install the `Windows 7.1 SDK <https://www.microsoft.com/en-us/download/details.aspx?id=8279>`__. Read the references below as there may be various gotchas during the installation.
223+
223224
For Python 3.5, you can download and install the `Visual Studio 2015 Community Edition <https://www.visualstudio.com/en-us/downloads/visual-studio-2015-downloads-vs.aspx>`__.
224225

225226
Here are some references:

pandas/tests/series/test_analytics.py

+17
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,16 @@ def test_mode(self):
160160
assert_series_equal(s.mode(), Series(['2011-01-03', '2013-01-02'],
161161
dtype='M8[ns]'))
162162

163+
# GH 5986
164+
s = Series(['1 days', '-1 days', '0 days'], dtype='timedelta64[ns]')
165+
assert_series_equal(s.mode(), Series([], dtype='timedelta64[ns]'))
166+
167+
s = Series(['1 day', '1 day', '-1 day', '-1 day 2 min',
168+
'2 min', '2 min'],
169+
dtype='timedelta64[ns]')
170+
assert_series_equal(s.mode(), Series(['2 min', '1 day'],
171+
dtype='timedelta64[ns]'))
172+
163173
def test_prod(self):
164174
self._check_stat_op('prod', np.prod)
165175

@@ -1015,6 +1025,13 @@ def test_rank(self):
10151025
iranks = iseries.rank()
10161026
assert_series_equal(iranks, exp)
10171027

1028+
# GH 5968
1029+
iseries = Series(['3 day', '1 day 10m', '-2 day', pd.NaT],
1030+
dtype='m8[ns]')
1031+
exp = Series([3, 2, 1, np.nan])
1032+
iranks = iseries.rank()
1033+
assert_series_equal(iranks, exp)
1034+
10181035
values = np.array(
10191036
[-50, -1, -1e-20, -1e-25, -1e-50, 0, 1e-40, 1e-20, 1e-10, 2, 40
10201037
], dtype='float64')

pandas/tests/test_algos.py

+14
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,20 @@ def test_datelike(self):
143143
[0, 0, 0, 1, 1, 0], dtype=np.int64))
144144
self.assert_numpy_array_equal(uniques, pd.PeriodIndex([v1, v2]))
145145

146+
# GH 5986
147+
v1 = pd.to_timedelta('1 day 1 min')
148+
v2 = pd.to_timedelta('1 day')
149+
x = Series([v1, v2, v1, v1, v2, v2, v1])
150+
labels, uniques = algos.factorize(x)
151+
self.assert_numpy_array_equal(labels, np.array(
152+
[0, 1, 0, 0, 1, 1, 0], dtype=np.int64))
153+
self.assert_numpy_array_equal(uniques, pd.to_timedelta([v1, v2]))
154+
155+
labels, uniques = algos.factorize(x, sort=True)
156+
self.assert_numpy_array_equal(labels, np.array(
157+
[1, 0, 1, 1, 0, 0, 1], dtype=np.int64))
158+
self.assert_numpy_array_equal(uniques, pd.to_timedelta([v2, v1]))
159+
146160
def test_factorize_nan(self):
147161
# nan should map to na_sentinel, not reverse_indexer[na_sentinel]
148162
# rizer.factorize should not raise an exception if na_sentinel indexes

0 commit comments

Comments
 (0)