You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "caneff (via GitHub)" <gi...@apache.org> on 2023/09/19 00:42:33 UTC

[GitHub] [beam] caneff commented on a diff in pull request #28500: Fix value_counts for Pandas 2

caneff commented on code in PR #28500:
URL: https://github.com/apache/beam/pull/28500#discussion_r1329423243


##########
sdks/python/apache_beam/dataframe/frames.py:
##########
@@ -2341,8 +2341,13 @@ def value_counts(
 
     result = column.groupby(column, dropna=dropna).size()
 
-    # groupby.size() names the index, which we don't need
-    result.index.name = None
+    # Pandas 2 introduces new naming for the results.
+    if PD_VERSION >= (2, 0):
+      result.index.name = getattr(self, "name", None)
+      result.name = "proportion" if normalize else "count"

Review Comment:
   Yes



-- 
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