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

Ability to internally store counts of each category in a CategoricalColumn #296

Merged
merged 5 commits into from
Jun 28, 2021

Conversation

az85252
Copy link
Contributor

@az85252 az85252 commented Jun 28, 2021

I have allowed the system to track the counts of each category rather than just a list. Like, instead of just listing the categories like [a,b,c], we can now internally have a way to count each category. The categories will return as before like [a,b,c], but inside, _categories variable is now something like [a:1,b:2,c:3].

…n_profile.py and test cases for categorical_column_profile.py that checks that categories is counted properly

self._categories = utils._combine_unique_sets(
self._categories, df_series)
self._categories.update(df_series.value_counts(dropna = False).to_dict())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no spaces around the = here dropna=False

Comment on lines 168 to 174

def dict_of_categories(self):
"""
Returns the dict of categories with the number of occurrences
for each category.
"""
return dict(self._categories.items())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of dict_of_categories, we could do a functional property category_counts and return a copy of the dict.
However, I suggest adding that to the subsequent PR which adds it to the profile.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now we can just remove this function.

@JGSweets JGSweets enabled auto-merge (squash) June 28, 2021 19:51
auto-merge was automatically disabled June 28, 2021 21:08

Head branch was pushed to by a user without write access

@JGSweets JGSweets enabled auto-merge (squash) June 28, 2021 21:34
@JGSweets JGSweets merged commit c81e2f5 into capitalone:main Jun 28, 2021
stevensecreti pushed a commit to stevensecreti/DataProfiler that referenced this pull request Jun 15, 2022
…olumn (capitalone#296)

* added function to store counts of each category for categorical_column_profile.py and test cases for categorical_column_profile.py that checks that categories is counted properly

* fixed grammer for categorical_column_profile.py

* added test case to validate count is correct for categorical column profile internally.

* removed unused function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants