Created
October 18, 2019 18:24
-
-
Save jeffbryner/fbce8a8ff0fd4874e09257760a25ad96 to your computer and use it in GitHub Desktop.
pandas threshold function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def pd_threshold(in_dict,column_name,threshold_count): | |
'''given a dictionary (or data frame), return a dictionary of the column values over a certain threshold''' | |
df=pd.DataFrame(in_dict) | |
df_count=df.groupby(column_name)[column_name].count() | |
return df_count[df_count.where(df_count>threshold_count)>threshold_count].to_dict() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment