def toCategorical(df):
    """
    This function change object datatype in pandas.DataFrame into category datatype.
    Parameters
    ----------
    df : pandas.DataFrame with train or test DataFrame.
    
    Returns
    -------
    df : pandas.DataFrame with new datatypes.
    
    """
    columns=['availability','group','content','unit','pharmForm',
             'campaignIndex','salesIndex', 'category', 'manufacturer']
    for col in columns:
        if col in df.columns:
            df[col]=df[col].astype('category')
    return df