I am writing a function which tries to find a 'string' from a column of a dataframe and then group the dataframe based on two other columns and count the values. However, I am getting a null key value after count which causes the issue while writing the dataframe back to MongoDB.
df is the dataframe with columns such as ConversationDate, panelistId, and contentType
def get_total_daily_interactions(df):
df['interactions_count_asr']=1
df_total_daily_interactions = df[df.contentType == 'ASR'].groupby(['conversationDate','panelistId']).count([['interactions_count_asr']]
return df_total_daily_interactions
This is what I am getting as an output
interactions_count_asr
conversationDate panelistId
4/26/2018 08d1b9b1-e99d-4c42-9ca5-9c9bc0b748e7 11
4/27/2018 08d1b9b1-e99d-4c42-9ca5-9c9bc0b748e7 3
4/29/2018 08d1b9b1-e99d-4c42-9ca5-9c9bc0b748e7 103
Why am I getting the 'Null' key value for intercations_count_asr? How can this code be improved? I want to have a dataframe which provides interactions_count for panelistId based on conversationDate.