def clean_data(df):
    """
    Function to load the data sets and clean the data (so as to give column names corresponding to the different categories).
    		
    Args: 
    The merged dataframe containing the messages and the categories
    		
    Returns: 
    Dataframe that has the messages and one column for each category.
    	
    """
    categories1 = df.categories
    categories2 = categories1.str.split(pat=';', n=-1, expand=True)
     
    # select the first row of the categories dataframe
    row = categories2.loc[0,:]
    
    # use this row to extract a list of new column names for categories.
    # one way is to apply a lambda function that takes everything 
    # up to the second to last character of each string with slicing
    category_colnames = row.apply(lambda x: x[:-2])
    
    # rename the columns of `categories`
    categories2.columns = category_colnames
    
    for column in categories2:
        # set each value to be the last character of the string
        categories2[column] = categories2[column].str[-1]
       
        # convert column from string to numeric and making it binary!
        
        categories2[column] = categories2[column].astype('float').astype('Int32') > 0
        
    categories2['id'] = df['id']
    
    # drop the original categories column from `df`
    df = df.drop(['categories'], axis=1)
    
    # concatenate the original dataframe with the new `categories` dataframe
    df2 = df.merge(categories2)
    
    return df2