BUG: Un-actionable FutureWarning in DataFrame.value_counts with categorical column(s) #54775
Closed
3 tasks done
Labels
Milestone
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
DataFrame.value_counts
issues aFutureWarning
when at least one of the columns has a categorical dtype. AFAICT, this warning is non-actionable by the user because it is triggered from a group by operation internal tovalue_counts
, and the relevant parameter (observed
) is not exposed in thevalue_counts
API.I guess the warning itself is valid and indicates that the behavior of
DataFrame.value_counts
is going to change in the future. But it is not correct that the user can pass a parameter to (a) ensure forward-compatibility and (b) make the warning go away.Expected Behavior
I think there's two options:
DataFrame.value_counts
could passobserved=False
internally to avoid triggering the warning and to prevent its behavior from changing in the future.DataFrame.value_counts
could expose theobserved
parameter so that users can control how the upcoming change toGroupBy
affects their code.Installed Versions
pd.show_versions
is erroring out for me, but my pandas version is2.1.0rc0
. I'll put the traceback in the details in case useful...The text was updated successfully, but these errors were encountered: