Shaving creams

In this page I will outline the most popular shaving creams in Brazil and their composition in order to analyze what they have in common and what are their exclusive ingredients. The code used for the analysis is also provided.

The analyzed shaving creams

These are the products used in the analysis, the data is also available in JSON format, which was used for the analysis.

“NIVEA MEN Sensitive”

Aqua, Glycerin, Myristic Acid, Palmitic Acid, Stearic Acid, Potassium Hydroxide, Glyceryl Stearate, PEG-8, Cera Alba, Parfum, Maris Sal, Chamomilla Recutita Flower Extract, Oleic Acid, Maltodextrin, Acrylates Copolymer, Sodium Methyl Cocoyl Taurate, Arachidic Acid, Sodium Lauryl Sulfate, Trisodium EDTA.

Web page. Accessed on 2019-08-02.

“BOZZANO Hidratação”

Aqua*, Stearic Acid, Glycerin*, Potassium Hydroxide, Orbignya Speciosa Kernel Oil, Parfum, Boric Acid, Aloe Barbadensis Leaf Extract, Sodium Hydroxide, Lanolin, Cellulose Gum, Lanolin Oil, Enteromorpha Compressa Extract*, Hydrolyzed Caesalpinia Spinosa Gum*, Caesalpinia Spinosa Gum*, Rheum Rhaponticum Root Extract*, Phenoxyethanol*, Sodium Benzoate*, Potassium Sorbate*, Linalool, Limonene, Hexyl Cinnamal.

Web page. Accessed on 2019-08-02.

“BOZZANO Refrescante”

Aqua*, Stearic Acid, Glycerin*, Potassium Hydroxide, Orbignya Speciosa Kernel Oil, Parfum, Boric Acid, Menthol, Sodium Hydroxide, Lanolin, Cellulose Gum, Lanolin Oil, Enteromorpha Compressa Extract*, Hydrolyzed Caesalpinia Spinosa Gum*, Caesalpinia Spinosa Gum*, Rheum Rhaponticum Root Extract*, Phenoxyethanol*, Sodium Benzoate*, Potassium Sorbate*, Linalool, Limonene, Hexyl Cinnamal.

Web page. Accessed on 2019-08-02.

“BOZZANO Pele Sensível”

Aqua*, Stearic Acid, Glycerin*, Potassium Hydroxide, Orbignya Speciosa Kernel Oil, Boric Acid, Helianthus Annuus Seed Oil, Menthol, Sodium Hydroxide, Lanolin, Cellulose Gum, Camphor, Thymol, Lanolin Oil, Enteromorpha Compressa Extract*, Eugenia Caryophyllus Flower Extract, Eucalyptus Globulus Leaf Extract, Mentha Piperita Leaf Extract, Hydrolyzed Caesalpinia Spinosa Gum*, Caesalpinia Spinosa Gum*, Rheum Rhaponticum Root Extract*, Phenoxyethanol*, Sodium Benzoate*, Potassium Sorbate*, BHT, Ascorbyl Palmitate.

Web page. Accessed on 2019-08-02.

Data in a JSON file

The data is available in this JSON file.

Analysis

There are 45 different ingredients in the above products.

The common ingredients

Four ingredients are common all across the board:

  • Glycerin
  • Potassium Hydroxide
  • Stearic Acid
  • Aqua

The exclusive ingredients

The following lists show the ingredients which only appear in a single product.

Exclusive to “NIVEA MEN Sensitive” (14)

  • Myristic Acid
  • Palmitic Acid
  • Glyceryl Stearate
  • PEG-8
  • Cera Alba
  • Maris Sal
  • Chamomilla Recutita Flower Extract
  • Oleic Acid
  • Maltodextrin
  • Acrylates Copolymer
  • Sodium Methyl Cocoyl Taurate
  • Arachidic Acid
  • Sodium Lauryl Sulfate
  • Trisodium EDTA

Exclusive to “BOZZANO Hidratação” (1)

  • Aloe Barbadensis Leaf Extract

Exclusive to “BOZZANO Refrescante” (0)

None.

Exclusive to “BOZZANO Pele Sensível” (8)

  • Helianthus Annuus Seed Oil
  • Camphor
  • Thymol
  • Eugenia Caryophyllus Flower Extract
  • Eucalyptus Globulus Leaf Extract
  • Mentha Piperita Leaf Extract
  • BHT
  • Ascorbyl Palmitate

Code to perform the analysis

The code used to perform the analysis is available below.

import collections
import json
import sys


def make_ingredient_list(ingredient_string):
    ingredients = ingredient_string.strip('.').split(',')
    ingredients = [ingredient.strip().strip('*') for ingredient in ingredients]
    return ingredients


def print_ingredient_list(list_name: str, ingredient_list: list):
    print('"{}" ({})'.format(list_name, len(ingredient_list)))
    for ingredient in ingredient_list:
        print('  {}'.format(ingredient))


if __name__ == '__main__':
    if len(sys.argv) != 2:
        print('Provide just the path to the JSON data file.')
        exit(1)
    products = {}
    with open(sys.argv[1]) as data_file_handle:
        data = json.load(data_file_handle)
        for key in data:
            products.update({key: data[key]})
    for product_name in products:
        products[product_name] = make_ingredient_list(products[product_name])
    ingredient_frequency = collections.Counter()
    for product_name in products:
        ingredient_frequency.update(products[product_name])
    print('Found {} different ingredients.'.format(len(ingredient_frequency)))
    common_ingredients = set()
    for ingredient in ingredient_frequency:
        if ingredient_frequency[ingredient] == len(products):
            common_ingredients.add(ingredient)
    print_ingredient_list('Common ingredients', list(common_ingredients))
    for product_name in products:
        exclusive = []
        for ingredient in products[product_name]:
            if ingredient_frequency[ingredient] == 1:
                exclusive.append(ingredient)
        print_ingredient_list('Exclusive to {}'.format(product_name), exclusive)