Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update categorical profiler #1136

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions dataprofiler/profilers/categorical_column_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
from typing import cast

import datasketches
from pandas import DataFrame, Series
import pandas as pd
import polars as pl
from polars import DataFrame, Series

from .. import dp_logging
from . import profiler_utils
Expand Down Expand Up @@ -601,7 +603,7 @@ def _get_categories_full(self, df_series) -> dict:
:return: dict of counts for each unique value
:rtype: dict
"""
category_count: dict = df_series.value_counts(dropna=False).to_dict()
category_count: dict = dict(df_series.value_counts(sort=True).iter_rows())
return category_count

@BaseColumnProfiler._timeit(name="categories")
Expand Down Expand Up @@ -678,6 +680,9 @@ def update(self, df_series: Series) -> CategoricalColumn:
:return: updated CategoricalColumn
:rtype: CategoricalColumn
"""
# TODO remove onces profiler builder is updated
if isinstance(df_series, pd.Series):
df_series = pl.from_pandas(df_series) # type: ignore
# If condition for limiting profile calculations
if len(df_series) == 0 or self._stop_condition_is_met:
return self
Expand Down
Loading