Skip to content
Advertisement

Tag: running-count

How to create rank column in Python based on other columns

I have a python dataframe that looks like the following: This dataframe has been sorted in descending order by ‘transaction_count’. I want to create another column in that dataframe called ‘rank’ that contains the count of occurrences of cust_ID. My desired output would look something like the following: For cust_ID = 1234 with transaction_count = 4, the rank would be

Iterating through pandas groupby groups

I have a pandas dataframe school_df that looks like this: Each row represents one project by that school. I’d like to add two columns: for each unique school_id, a count of how many projects were posted before that date and a count of how many projects were completed before that date. The code below works, but I have ~300,000 unique

Advertisement