|
4 | 4 | import pytest
|
5 | 5 |
|
6 | 6 | from pandas import (DataFrame, Index, MultiIndex, Period, Series, Timedelta,
|
7 |
| - Timestamp) |
| 7 | + Timestamp) |
8 | 8 | import pandas._testing as tm
|
9 | 9 |
|
10 | 10 |
|
@@ -222,54 +222,20 @@ def test_count_with_only_nans_in_first_group(self):
|
222 | 222 | expected = Series([], index=mi, dtype=np.int64, name="C")
|
223 | 223 | tm.assert_series_equal(result, expected, check_index_type=False)
|
224 | 224 |
|
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 |
| - |
235 | 225 | def test_count_groupby_index_with_nan_in_index(self):
|
236 | 226 | # https://github.com/pandas-dev/pandas/issues/21824
|
237 | 227 | 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]}) |
240 | 230 |
|
241 | 231 | res = df.set_index(["Person", "Single"]).count(level="Person")
|
242 | 232 | expected = DataFrame(index=Index(["John", "Myla"], name="Person"),
|
243 | 233 | data={"Age": [2, 2]})
|
244 | 234 |
|
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 |
| - |
256 | 235 | def test_count_groupby_column_with_nan_in_groupby_column(self):
|
| 236 | + # https://github.com/pandas-dev/pandas/issues/32841 |
257 | 237 | df = DataFrame({"A": [1, 1, 1, 1, 1], "B": [5, 4, np.NaN, 3, 0]})
|
258 | 238 | res = df.groupby(["B"]).count()
|
259 | 239 | expected = DataFrame(index=Index([0.0, 3.0, 4.0, 5.0], name="B"),
|
260 | 240 | data={"A": [1, 1, 1, 1]})
|
261 | 241 | 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