Skip to content

Commit 1e755b3

Browse files
committed
Clean up tests.
1 parent 049b897 commit 1e755b3

File tree

1 file changed

+4
-38
lines changed

1 file changed

+4
-38
lines changed

pandas/tests/groupby/test_counting.py

+4-38
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pytest
55

66
from pandas import (DataFrame, Index, MultiIndex, Period, Series, Timedelta,
7-
Timestamp)
7+
Timestamp)
88
import pandas._testing as tm
99

1010

@@ -222,54 +222,20 @@ def test_count_with_only_nans_in_first_group(self):
222222
expected = Series([], index=mi, dtype=np.int64, name="C")
223223
tm.assert_series_equal(result, expected, check_index_type=False)
224224

225-
#def test_count_groupby_index_with_nan_in_data(self):
226-
# # https://github.com/pandas-dev/pandas/issues/21824
227-
# df = DataFrame({"Person": ["John", "Myla", "John", "John", "Myla"],
228-
# "Age": [24., np.nan, 21., 33, 26],
229-
# "Single": [False, True, True, True, False]})
230-
231-
# res = df.set_index(["Person", "Single"]).count(level="Person")
232-
# expected = DataFrame(index=Index(["John", "Myla"], name="Person"),
233-
# data={"Age": [2, 1]})
234-
235225
def test_count_groupby_index_with_nan_in_index(self):
236226
# https://github.com/pandas-dev/pandas/issues/21824
237227
df = DataFrame({"Person": ["John", "Myla", None, "John", "Myla"],
238-
"Age": [24., 5, 21., 33, 26],
239-
"Single": [False, True, True, True, False]})
228+
"Age": [24., 5, 21., 33, 26],
229+
"Single": [False, True, True, True, False]})
240230

241231
res = df.set_index(["Person", "Single"]).count(level="Person")
242232
expected = DataFrame(index=Index(["John", "Myla"], name="Person"),
243233
data={"Age": [2, 2]})
244234

245-
#def test_count_groupby_index_with_nan_in_data_and_in_index(self):
246-
# # https://github.com/pandas-dev/pandas/issues/21824
247-
# df = DataFrame({"Person": ["John", "Myla", None, "John", "Myla"],
248-
# "Age": [24., np.nan, 21., 33, 26],
249-
# "Single": [False, True, True, True, False]})
250-
251-
# res = df.set_index(["Person", "Single"]).count(level="Person")
252-
# expected = DataFrame(index=Index(["John", "Myla"], name="Person"),
253-
# data={"Age": [2, 1]})
254-
255-
256235
def test_count_groupby_column_with_nan_in_groupby_column(self):
236+
# https://github.com/pandas-dev/pandas/issues/32841
257237
df = DataFrame({"A": [1, 1, 1, 1, 1], "B": [5, 4, np.NaN, 3, 0]})
258238
res = df.groupby(["B"]).count()
259239
expected = DataFrame(index=Index([0.0, 3.0, 4.0, 5.0], name="B"),
260240
data={"A": [1, 1, 1, 1]})
261241
tm.assert_frame_equal(expected, res)
262-
263-
#def test_count_groupby_column_with_nan_in_data(self):
264-
# df = DataFrame({"A": [1, np.NaN, 1, 1, 1], "B": [5, 4., 2, 3, 0]})
265-
# res = df.groupby(["B"]).count()
266-
# expected = DataFrame(index=Index([0.0, 2.0, 3.0, 4.0, 5.0], name="B"),
267-
# data={"A": [1, 1, 1, 0, 1]})
268-
# tm.assert_frame_equal(expected, res)
269-
270-
#def test_count_groupby_column_with_nan_in_data_and_in_groupby_column(self):
271-
# df = DataFrame({"A": [1, np.NaN, 1, 1, 1], "B": [5, 4, np.NaN, 3, 0]})
272-
# res = df.groupby(["B"]).count()
273-
# expected = DataFrame(index=Index([0.0, 3.0, 4.0, 5.0], name="B"),
274-
# data={"A": [1, 1, 0, 1]})
275-
# tm.assert_frame_equal(expected, res)

0 commit comments

Comments
 (0)