Skip to content

Commit 073f22d

Browse files
committed
Add whatsnew, use np.atleast_2d, add comment
1 parent 1ed0f48 commit 073f22d

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

doc/source/whatsnew/v0.21.1.txt

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Bug Fixes
6060
- Bug in :class:`TimedeltaIndex` subtraction could incorrectly overflow when ``NaT`` is present (:issue:`17791`)
6161
- Bug in :class:`DatetimeIndex` subtracting datetimelike from DatetimeIndex could fail to overflow (:issue:`18020`)
6262
- Bug in ``pd.Series.rolling.skew()`` and ``rolling.kurt()`` with all equal values has floating issue (:issue:`18044`)
63+
- Bug in ``pd.DataFrameGroupBy.count()`` when counting over a datetimelike column (:issue:`13393`)
6364

6465
Conversion
6566
^^^^^^^^^^

pandas/core/groupby.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -4365,9 +4365,7 @@ def count(self):
43654365
ids, _, ngroups = self.grouper.group_info
43664366
mask = ids != -1
43674367

4368-
makeNDarray = lambda vals: vals[None, :] if vals.ndim == 1 else vals
4369-
4370-
val = ((mask & ~isna(makeNDarray(blk.get_values())))
4368+
val = ((mask & ~isna(np.atleast_2d(blk.get_values())))
43714369
for blk in data.blocks)
43724370
loc = (blk.mgr_locs for blk in data.blocks)
43734371

pandas/tests/groupby/test_counting.py

+1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ def test_ngroup_respects_groupby_order(self):
197197
g.cumcount())
198198

199199
def test_count_with_datetime(self):
200+
# test for #13393
200201
df = DataFrame({'x': ['a', 'a', 'b'],
201202
'y': [Timestamp('2016-05-07 20:09:25+00:00'),
202203
Timestamp('2016-05-07 20:09:29+00:00'),

0 commit comments

Comments
 (0)