31
31
import numpy as np
32
32
33
33
from pandas ._libs import lib
34
- from pandas ._typing import FrameOrSeries , FrameOrSeriesUnion
34
+ from pandas ._typing import FrameOrSeries , FrameOrSeriesUnion , Scalar
35
35
from pandas .util ._decorators import Appender , Substitution , doc
36
36
37
37
from pandas .core .dtypes .cast import (
@@ -1788,7 +1788,9 @@ def _wrap_transformed_output(
1788
1788
1789
1789
return result
1790
1790
1791
- def _wrap_agged_blocks (self , blocks : "Sequence[Block]" , items : Index ) -> DataFrame :
1791
+ def _wrap_agged_blocks (
1792
+ self , blocks : "Sequence[Block]" , items : Index , fill_value : Scalar = np .NaN
1793
+ ) -> DataFrame :
1792
1794
if not self .as_index :
1793
1795
index = np .arange (blocks [0 ].values .shape [- 1 ])
1794
1796
mgr = BlockManager (blocks , axes = [items , index ])
@@ -1804,7 +1806,7 @@ def _wrap_agged_blocks(self, blocks: "Sequence[Block]", items: Index) -> DataFra
1804
1806
if self .axis == 1 :
1805
1807
result = result .T
1806
1808
1807
- return self ._reindex_output (result )._convert (datetime = True )
1809
+ return self ._reindex_output (result , fill_value )._convert (datetime = True )
1808
1810
1809
1811
def _iterate_column_groupbys (self ):
1810
1812
for i , colname in enumerate (self ._selected_obj .columns ):
@@ -1846,7 +1848,7 @@ def count(self):
1846
1848
)
1847
1849
blocks = [make_block (val , placement = loc ) for val , loc in zip (counted , locs )]
1848
1850
1849
- return self ._wrap_agged_blocks (blocks , items = data .items )
1851
+ return self ._wrap_agged_blocks (blocks , items = data .items , fill_value = 0 )
1850
1852
1851
1853
def nunique (self , dropna : bool = True ):
1852
1854
"""
0 commit comments