app/run.py
def cat_dist(df):
    ''' This function calculates the total numbber of messages per category.
    
    If the input is invalid or the data does not exist, this function will raise an error.
    
    INPUT:
    df --> a Pandas DataFrame containing the prepared data
    
    OUTPUT:
    msg_count --> a Pandas DataFrame containing the message counts for each category
    categories --> the list of categories from the dataset
    '''
    categories = df.drop(['id', 'message', 'original', 'genre'], axis=1).columns
    count = []
    for category in categories:
        count.append(len(df[df[category] != 0]))
    cat_msg_counts_df = pd.DataFrame(count, columns=['Message Counts'], index=categories)
    msg_count = cat_msg_counts_df.sort_values(by=['Message Counts'], ascending=False)
    msg_count = msg_count['Message Counts']
    return msg_count, categories
 This function calculates the total numbber of messages per category.
    
    If the input is invalid or the data does not exist, this function will raise an error.
    
    INPUT:
    df --> a Pandas DataFrame containing the prepared data
    
    OUTPUT:
    msg_count --> a Pandas DataFrame containing the message counts for each category
    categories --> the list of categories from the dataset
    
This function calculates the total numbber of messages per category.
If the input is invalid or the data does not exist, this function will raise an error.

-> a Pandas DataFrame containing the prepared data

-> a Pandas DataFrame containing the message counts for each category
categories --> the list of categories from the dataset
This function calculates the total numbber of messages per category . If the input is invalid or the data does not exist this function will raise an error . - > a Pandas DataFrame containing the prepared data - > a Pandas DataFrame containing the message counts for each category categories -- > the list of categories from the dataset
def cat_dist(df):
    categories = df.drop(['id', 'message', 'original', 'genre'], axis=1).columns
    count = []
    for category in categories:
        count.append(len(df[df[category] != 0]))
    cat_msg_counts_df = pd.DataFrame(count, columns=['Message Counts'], index=categories)
    msg_count = cat_msg_counts_df.sort_values(by=['Message Counts'], ascending=False)
    msg_count = msg_count['Message Counts']
    return msg_count, categories
def cat_dist ( df ) : categories = df . drop ( [ 'id' , 'message' , 'original' , 'genre' ] , axis = 1 ) . columns count = [ ] for category in categories : count . append ( len ( df [ df [ category ] != 0 ] ) ) cat_msg_counts_df = pd . DataFrame ( count , columns = [ 'Message Counts' ] , index = categories ) msg_count = cat_msg_counts_df . sort_values ( by = [ 'Message Counts' ] , ascending = False ) msg_count = msg_count [ 'Message Counts' ] return msg_count , categories
This function calculates the total numbber of messages per category.
This function calculates the total numbber of messages per category .
''' This function calculates the total numbber of messages per category.
    
    If the input is invalid or the data does not exist, this function will raise an error.
    
    INPUT:
    df --> a Pandas DataFrame containing the prepared data
    
    OUTPUT:
    msg_count --> a Pandas DataFrame containing the message counts for each category
    categories --> the list of categories from the dataset
    '''
df