def augment_products(products, top_n):
    """
    Add additional product features based on frequency/name

    Args:
        products (pd.DataFrame): All products in data with n_orders column already calculated
        top_n (int): number of top orders to designate as "popular" products

    Returns:
        pd.DataFrame: original data with features appended for "popular" and "organic"

    """
    # Product considered "popular" if among the top_n products ordered in its department
    top_products = products.groupby('department_id')['n_orders']\
        .nlargest(top_n).reset_index()
    top_products = top_products.join(
        products[['product_name']], on='product_id')
    top_products = top_products.values.reshape(-1)
    products['popular'] = products['product_name'].isin(
        top_products).astype(int)

    products['organic'] = products['product_name'].str.lower()\
        .str.contains('organic').astype(int)

    return products