You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "anishmehta24 (via GitHub)" <gi...@apache.org> on 2026/10/11 01:50:04 UTC

[I] [Bug]: DataFrame API agg(['count', ...]) labels the count/size row as 'sum' [beam]

anishmehta24 opened a new issue, #40504:
URL: https://github.com/apache/beam/issues/40504

   ### What happened?
   
   With the DataFrame API, `agg` with a list that includes `'count'` or `'size'` gives the right numbers, but those rows come back labelled `sum` instead of `count`/`size`.
   
   ```python
   import apache_beam as beam
   import numpy as np
   import pandas as pd
   from apache_beam.dataframe.convert import to_dataframe, to_pcollection
   
   pdf = pd.DataFrame({'x': [1.0, np.nan, 3.0], 'y': [10, 20, 30]})
   print(pdf.agg(['count', 'mean']))
   
   with beam.Pipeline() as p:
     df = to_dataframe(p | beam.Create([pdf]), proxy=pdf[:0])
     _ = (
         to_pcollection(
             df.agg(['count', 'mean']),
             include_indexes=True,
             yield_elements='pandas')
         | beam.Map(print))
   ```
   
   pandas:
   
   ```
            x     y
   count  2.0   3.0
   mean   2.0  20.0
   ```
   
   Beam:
   
   ```
           x     y
   sum   2.0   3.0
   mean  2.0  20.0
   ```
   
   `Series.agg(['count'])` and `Series.agg(['size'])` have the same problem.
   
   count and size are computed per partition and then combined with a sum. When `func` is a list, `DeferredSeries.aggregate` does that last step with `s.agg(['sum'])`, so the row label becomes `sum` (sdks/python/apache_beam/dataframe/frames.py, the `agg_func = ['sum'] if isinstance(func, list) else 'sum'` line).
   
   Seen on Beam 2.77.0 and on master (7d93ef8e76a), pandas 2.3.3, Python 3.12.
   
   ### Issue Priority
   
   Priority: 2 (default / most bugs should be filed as P2)
   
   ### Issue Components
   
   - [x] Component: Python SDK
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: DataFrame API agg(['count', ...]) labels the count/size row as 'sum' [beam]

Posted by "damccorm (via GitHub)" <gi...@apache.org>.
damccorm closed issue #40504: [Bug]: DataFrame API agg(['count', ...]) labels the count/size row as 'sum'
URL: https://github.com/apache/beam/issues/40504


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug]: DataFrame API agg(['count', ...]) labels the count/size row as 'sum' [beam]

Posted by "anishmehta24 (via GitHub)" <gi...@apache.org>.
anishmehta24 commented on issue #40504:
URL: https://github.com/apache/beam/issues/40504#issuecomment-6104348269

   .take-issue


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org