Skip to content

Commit 5f36395

Browse files
author
Robin
committed
Fixed flake issues, removed duplicate test, inserted GH issue number reference
1 parent 5f829e1 commit 5f36395

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

pandas/tests/frame/test_analytics.py

+16-8
Original file line numberDiff line numberDiff line change
@@ -809,18 +809,23 @@ def test_mode(self):
809809
"E": [8, 8, 1, 1, 3, 3]})
810810
tm.assert_frame_equal(df[["A"]].mode(),
811811
pd.DataFrame({"A": [12]}))
812-
expected = pd.Series([0, 1, 2, 3, 4, 5], dtype='int64', name='D').to_frame()
812+
expected = pd.Series([0, 1, 2, 3, 4, 5], dtype='int64', name='D').\
813+
to_frame()
813814
tm.assert_frame_equal(df[["D"]].mode(), expected)
814815
expected = pd.Series([1, 3, 8], dtype='int64', name='E').to_frame()
815816
tm.assert_frame_equal(df[["E"]].mode(), expected)
816817
tm.assert_frame_equal(df[["A", "B"]].mode(),
817818
pd.DataFrame({"A": [12], "B": [10.]}))
818819
tm.assert_frame_equal(df.mode(),
819-
pd.DataFrame({"A": [12, np.nan, np.nan, np.nan, np.nan, np.nan],
820-
"B": [10, np.nan, np.nan, np.nan, np.nan, np.nan],
821-
"C": [8, 9, np.nan, np.nan, np.nan, np.nan],
820+
pd.DataFrame({"A": [12, np.nan, np.nan, np.nan,
821+
np.nan, np.nan],
822+
"B": [10, np.nan, np.nan, np.nan,
823+
np.nan, np.nan],
824+
"C": [8, 9, np.nan, np.nan, np.nan,
825+
np.nan],
822826
"D": [0, 1, 2, 3, 4, 5],
823-
"E": [1, 3, 8, np.nan, np.nan, np.nan]}))
827+
"E": [1, 3, 8, np.nan, np.nan,
828+
np.nan]}))
824829

825830
# outputs in sorted order
826831
df["C"] = list(reversed(df["C"]))
@@ -837,9 +842,12 @@ def test_mode(self):
837842
df = pd.DataFrame({"A": np.arange(6, dtype='int64'),
838843
"B": pd.date_range('2011', periods=6),
839844
"C": list('abcdef')})
840-
exp = pd.DataFrame({"A": pd.Series(np.arange(6, dtype='int64'), dtype=df["A"].dtype),
841-
"B": pd.Series(pd.date_range('2011', periods=6), dtype=df["B"].dtype),
842-
"C": pd.Series(list('abcdef'), dtype=df["C"].dtype)})
845+
exp = pd.DataFrame({"A": pd.Series(np.arange(6, dtype='int64'),
846+
dtype=df["A"].dtype),
847+
"B": pd.Series(pd.date_range('2011', periods=6),
848+
dtype=df["B"].dtype),
849+
"C": pd.Series(list('abcdef'),
850+
dtype=df["C"].dtype)})
843851
tm.assert_frame_equal(df.mode(), exp)
844852

845853
def test_operators_timedelta64(self):

pandas/tests/series/test_analytics.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def test_mode(self):
133133
exp = Series([1], dtype=np.int64)
134134
tm.assert_series_equal(Series([1]).mode(), exp)
135135

136-
exp = Series(['a','b','c'], dtype=np.object)
136+
exp = Series(['a', 'b', 'c'], dtype=np.object)
137137
tm.assert_series_equal(Series(['a', 'b', 'c']).mode(), exp)
138138

139139
# Test numerical data types.
@@ -170,7 +170,7 @@ def test_mode(self):
170170

171171
# Test datetime types.
172172
exp = Series(['1900-05-03', '2011-01-03',
173-
'2013-01-02'], dtype='M8[ns]')
173+
'2013-01-02'], dtype='M8[ns]')
174174
s = Series(['2011-01-03', '2013-01-02',
175175
'1900-05-03'], dtype='M8[ns]')
176176
tm.assert_series_equal(s.mode(), exp)

pandas/tests/test_algos.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,7 @@ def test_no_mode(self):
12561256
exp = Series([], dtype=np.float64)
12571257
tm.assert_series_equal(algos.mode([]), exp)
12581258

1259+
# GH 15714
12591260
def test_mode_single(self):
12601261
exp_single = [1]
12611262
data_single = [1]
@@ -1271,15 +1272,6 @@ def test_mode_single(self):
12711272
exp = Series(['a', 'b', 'c'], dtype=np.object)
12721273
tm.assert_series_equal(algos.mode(['a', 'b', 'c']), exp)
12731274

1274-
def test_mode_single(self):
1275-
exp_single = [1]
1276-
data_single = [1]
1277-
1278-
for dt in np.typecodes['AllInteger'] + np.typecodes['Float']:
1279-
s = Series(data_single, dtype=dt)
1280-
exp = Series(exp_single, dtype=dt)
1281-
tm.assert_series_equal(algos.mode(s), exp)
1282-
12831275
def test_number_mode(self):
12841276
exp_single = [1]
12851277
data_single = [1] * 5 + [2] * 3

0 commit comments

Comments
 (0)