{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Comparing Cosmetics by Ingredients\n", "> Buying new cosmetic products is difficult. It can even be scary for those who have sensitive skin and are prone to skin trouble. The information needed to alleviate this problem is on the back of each product, but it's tought to interpret those ingredient lists unless you have a background in chemistry.\n", " Instead of buying and hoping for the best, we can use data science to help us predict which products may be good fits for us. In this Project, you are going to create a content-based recommendation system where the 'content' will be the chemical components of cosmetics. Specifically, you will process ingredient lists for 1472 cosmetics on Sephora via word embedding, then visualize ingredient similarity using a machine learning method called t-SNE and an interactive visualization library called Bokeh. This is the Result of Project \"Comparing Cosmetics by Ingredients\", via datacamp.\n", "\n", "- toc: true \n", "- badges: true\n", "- comments: true\n", "- author: Chanseok Kang\n", "- categories: [Python, Datacamp, Data_Science, Visualization]\n", "- image: images/image_3.PNG" ] }, { "cell_type": "markdown", "metadata": { "dc": { "key": "4" }, "deletable": false, "run_control": { "frozen": true }, "tags": [ "context" ] }, "source": [ "## 1. Cosmetics, chemicals... it's complicated\n", "

Whenever I want to try a new cosmetic item, it's so difficult to choose. It's actually more than difficult. It's sometimes scary because new items that I've never tried end up giving me skin trouble. We know the information we need is on the back of each product, but it's really hard to interpret those ingredient lists unless you're a chemist. You may be able to relate to this situation.

\n", "

\n", "

So instead of buying and hoping for the best, why don't we use data science to help us predict which products may be good fits for us? In this notebook, we are going to create a content-based recommendation system where the 'content' will be the chemical components of cosmetics. Specifically, we will process ingredient lists for 1472 cosmetics on Sephora via word embedding, then visualize ingredient similarity using a machine learning method called t-SNE and an interactive visualization library called Bokeh. Let's inspect our data first.

" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "dc": { "key": "4" }, "tags": [ "sample_code" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
LabelBrandNamePriceRankIngredientsCombinationDryNormalOilySensitive
986Face MaskCLARINSExtra-Firming Mask764.9Water, Glycerin, Caprylic/Capric Triglyceride,...11111
256MoisturizerPERRICONE MDHigh Potency Classics: Face Finishing & Firmin...694.3Water, Ethylhexyl Palmitate, Glycerin, Aleurit...11101
481CleanserCLINIQUEBlackhead Solutions 7 Day Deep Pore Cleanse & ...244.2Water, Kaolin, Glycerin, Butylene Glycol, Magn...11111
100MoisturizerPERRICONE MDCold Plasma Sub-D Firming Neck Treatment1353.8Water, Glycolic Acid, L-Tyrosine, Dimethyl MEA...11111
708TreatmentLANCERYounger® Pure Youth Serum with MIMIXYL™2755.0Water, Aloe Barbadensis Leaf Extract, Dimethyl...11100
\n", "
" ], "text/plain": [ " Label Brand \\\n", "986 Face Mask CLARINS \n", "256 Moisturizer PERRICONE MD \n", "481 Cleanser CLINIQUE \n", "100 Moisturizer PERRICONE MD \n", "708 Treatment LANCER \n", "\n", " Name Price Rank \\\n", "986 Extra-Firming Mask 76 4.9 \n", "256 High Potency Classics: Face Finishing & Firmin... 69 4.3 \n", "481 Blackhead Solutions 7 Day Deep Pore Cleanse & ... 24 4.2 \n", "100 Cold Plasma Sub-D Firming Neck Treatment 135 3.8 \n", "708 Younger® Pure Youth Serum with MIMIXYL™ 275 5.0 \n", "\n", " Ingredients Combination Dry \\\n", "986 Water, Glycerin, Caprylic/Capric Triglyceride,... 1 1 \n", "256 Water, Ethylhexyl Palmitate, Glycerin, Aleurit... 1 1 \n", "481 Water, Kaolin, Glycerin, Butylene Glycol, Magn... 1 1 \n", "100 Water, Glycolic Acid, L-Tyrosine, Dimethyl MEA... 1 1 \n", "708 Water, Aloe Barbadensis Leaf Extract, Dimethyl... 1 1 \n", "\n", " Normal Oily Sensitive \n", "986 1 1 1 \n", "256 1 0 1 \n", "481 1 1 1 \n", "100 1 1 1 \n", "708 1 0 0 " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "Moisturizer 298\n", "Cleanser 281\n", "Face Mask 266\n", "Treatment 248\n", "Eye cream 209\n", "Sun protect 170\n", "Name: Label, dtype: int64" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Import libraries\n", "import pandas as pd\n", "import numpy as np\n", "from sklearn.manifold import TSNE\n", "\n", "# Load the data\n", "df = pd.read_csv('./dataset/cosmetics.csv')\n", "\n", "# Check the first five rows \n", "display(df.sample(5))\n", "\n", "# Inspect the types of products\n", "df['Label'].value_counts()" ] }, { "cell_type": "markdown", "metadata": { "dc": { "key": "12" }, "deletable": false, "editable": false, "run_control": { "frozen": true }, "tags": [ "context" ] }, "source": [ "## 2. Focus on one product category and one skin type\n", "

There are six categories of product in our data (moisturizers, cleansers, face masks, eye creams, and sun protection) and there are five different skin types (combination, dry, normal, oily and sensitive). Because individuals have different product needs as well as different skin types, let's set up our workflow so its outputs (a t-SNE model and a visualization of that model) can be customized. For the example in this notebook, let's focus in on moisturizers for those with dry skin by filtering the data accordingly.

" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "dc": { "key": "12" }, "tags": [ "sample_code" ] }, "outputs": [], "source": [ "# Filter for moisturizers\n", "moisturizers = df[df['Label'] == 'Moisturizer']\n", "\n", "# Filter for dry skin as well\n", "moisturizers_dry = moisturizers[moisturizers['Dry'] == 1]\n", "\n", "# Reset index\n", "moisturizers_dry = moisturizers_dry.reset_index(drop=True)" ] }, { "cell_type": "markdown", "metadata": { "dc": { "key": "19" }, "deletable": false, "editable": false, "run_control": { "frozen": true }, "tags": [ "context" ] }, "source": [ "## 3. Tokenizing the ingredients\n", "

To get to our end goal of comparing ingredients in each product, we first need to do some preprocessing tasks and bookkeeping of the actual words in each product's ingredients list. The first step will be tokenizing the list of ingredients in Ingredients column. After splitting them into tokens, we'll make a binary bag of words. Then we will create a dictionary with the tokens, ingredient_idx, which will have the following format:

\n", "

{ \"ingredient\": index value, … }

" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "dc": { "key": "19" }, "tags": [ "sample_code" ] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The index for decyl oleate is 25\n" ] } ], "source": [ "# Initialize dictionary, list, and initial index\n", "ingredient_idx = {}\n", "corpus = []\n", "idx = 0\n", "\n", "# For loop for tokenization\n", "for i in range(len(moisturizers_dry)): \n", " ingredients = moisturizers_dry['Ingredients'][i]\n", " ingredients_lower = ingredients.lower()\n", " tokens = ingredients_lower.split(', ')\n", " corpus.append(tokens)\n", " for ingredient in tokens:\n", " if ingredient not in ingredient_idx:\n", " ingredient_idx[ingredient] = idx\n", " idx += 1\n", " \n", "# Check the result \n", "print(\"The index for decyl oleate is\", ingredient_idx['decyl oleate'])" ] }, { "cell_type": "markdown", "metadata": { "dc": { "key": "26" }, "deletable": false, "editable": false, "run_control": { "frozen": true }, "tags": [ "context" ] }, "source": [ "## 4. Initializing a document-term matrix (DTM)\n", "

The next step is making a document-term matrix (DTM). Here each cosmetic product will correspond to a document, and each chemical composition will correspond to a term. This means we can think of the matrix as a “cosmetic-ingredient” matrix. The size of the matrix should be as the picture shown below.\n", "\n", "To create this matrix, we'll first make an empty matrix filled with zeros. The length of the matrix is the total number of cosmetic products in the data. The width of the matrix is the total number of ingredients. After initializing this empty matrix, we'll fill it in the following tasks.

" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "dc": { "key": "26" }, "tags": [ "sample_code" ] }, "outputs": [], "source": [ "# Get the number of items and tokens \n", "M = moisturizers_dry.shape[0]\n", "N = len(ingredient_idx)\n", "\n", "# Initialize a matrix of zeros\n", "A = np.zeros((M, N))" ] }, { "cell_type": "markdown", "metadata": { "dc": { "key": "33" }, "deletable": false, "editable": false, "run_control": { "frozen": true }, "tags": [ "context" ] }, "source": [ "## 5. Creating a counter function\n", "

Before we can fill the matrix, let's create a function to count the tokens (i.e., an ingredients list) for each row. Our end goal is to fill the matrix with 1 or 0: if an ingredient is in a cosmetic, the value is 1. If not, it remains 0. The name of this function, oh_encoder, will become clear next.

" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "dc": { "key": "33" }, "tags": [ "sample_code" ] }, "outputs": [], "source": [ "# Define the oh_encoder function\n", "def oh_encoder(tokens):\n", " x = np.zeros(A.shape[1])\n", " for ingredient in tokens:\n", " # Get the index for each ingredient\n", " idx = ingredient_idx[ingredient]\n", " # Put 1 at the corresponding indices\n", " x[idx] = 1\n", " return x" ] }, { "cell_type": "markdown", "metadata": { "dc": { "key": "40" }, "deletable": false, "editable": false, "run_control": { "frozen": true }, "tags": [ "context" ] }, "source": [ "## 6. The Cosmetic-Ingredient matrix!\n", "

Now we'll apply the oh_encoder() functon to the tokens in corpus and set the values at each row of this matrix. So the result will tell us what ingredients each item is composed of. For example, if a cosmetic item contains water, niacin, decyl aleate and sh-polypeptide-1, the outcome of this item will be as follows. \n", "\n", "This is what we called one-hot encoding. By encoding each ingredient in the items, the Cosmetic-Ingredient matrix will be filled with binary values.

" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "dc": { "key": "40" }, "tags": [ "sample_code" ] }, "outputs": [], "source": [ "# Make a document-term matrix\n", "i = 0\n", "for tokens in corpus:\n", " A[i, :] = oh_encoder(tokens)\n", " i += 1" ] }, { "cell_type": "markdown", "metadata": { "dc": { "key": "47" }, "deletable": false, "editable": false, "run_control": { "frozen": true }, "tags": [ "context" ] }, "source": [ "## 7. Dimension reduction with t-SNE\n", "

The dimensions of the existing matrix is (190, 2233), which means there are 2233 features in our data. For visualization, we should downsize this into two dimensions. We'll use t-SNE for reducing the dimension of the data here.

\n", "

T-distributed Stochastic Neighbor Embedding (t-SNE) is a nonlinear dimensionality reduction technique that is well-suited for embedding high-dimensional data for visualization in a low-dimensional space of two or three dimensions. Specifically, this technique can reduce the dimension of data while keeping the similarities between the instances. This enables us to make a plot on the coordinate plane, which can be said as vectorizing. All of these cosmetic items in our data will be vectorized into two-dimensional coordinates, and the distances between the points will indicate the similarities between the items.

" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "dc": { "key": "47" }, "tags": [ "sample_code" ] }, "outputs": [], "source": [ "# Dimension reduction with t-SNE\n", "model = TSNE(n_components=2, learning_rate=200, random_state=42)\n", "tsne_features = model.fit_transform(A)\n", "\n", "# Make X, Y columns \n", "moisturizers_dry['X'] = tsne_features[:, 0]\n", "moisturizers_dry['Y'] = tsne_features[:, 1]" ] }, { "cell_type": "markdown", "metadata": { "dc": { "key": "55" }, "deletable": false, "editable": false, "run_control": { "frozen": true }, "tags": [ "context" ] }, "source": [ "## 8. Let's map the items with Bokeh\n", "

We are now ready to start creating our plot. With the t-SNE values, we can plot all our items on the coordinate plane. And the coolest part here is that it will also show us the name, the brand, the price and the rank of each item. Let's make a scatter plot using Bokeh and add a hover tool to show that information. Note that we won't display the plot yet as we will make some more additions to it.

" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "dc": { "key": "55" }, "tags": [ "sample_code" ] }, "outputs": [ { "data": { "text/html": [ "
GlyphRenderer(
id = '1037', …)
data_source = ColumnDataSource(id='1001', ...),
glyph = Circle(id='1035', ...),
hover_glyph = None,
js_event_callbacks = {},
js_property_callbacks = {},
level = 'glyph',
muted = False,
muted_glyph = None,
name = None,
nonselection_glyph = Circle(id='1036', ...),
selection_glyph = None,
subscribed_events = [],
tags = [],
view = CDSView(id='1038', ...),
visible = True,
x_range_name = 'default',
y_range_name = 'default')
\n", "\n" ], "text/plain": [ "GlyphRenderer(id='1037', ...)" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from bokeh.io import show, output_file\n", "from bokeh.plotting import figure\n", "from bokeh.models import ColumnDataSource, HoverTool\n", "from IPython.display import HTML\n", "\n", "# Make a source and a scatter plot \n", "source = ColumnDataSource(moisturizers_dry)\n", "plot = figure(x_axis_label = 'T-SNE 1', \n", " y_axis_label = 'T-SNE 2', \n", " width = 500, height = 400)\n", "plot.circle(x = 'X', \n", " y = 'Y', \n", " source = source, \n", " size = 10, color = '#FF7373', alpha = .8)" ] }, { "cell_type": "markdown", "metadata": { "dc": { "key": "62" }, "deletable": false, "editable": false, "run_control": { "frozen": true }, "tags": [ "context" ] }, "source": [ "## 9. Adding a hover tool\n", "

Why don't we add a hover tool? Adding a hover tool allows us to check the information of each item whenever the cursor is directly over a glyph. We'll add tooltips with each product's name, brand, price, and rank (i.e., rating).

" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "dc": { "key": "62" }, "tags": [ "sample_code" ] }, "outputs": [], "source": [ "# Create a HoverTool object\n", "hover = HoverTool(tooltips = [('Item', '@Name'),\n", " ('Brand', '@Brand'),\n", " ('Price', '$@Price'),\n", " ('Rank', '@Rank')])\n", "plot.add_tools(hover)" ] }, { "cell_type": "markdown", "metadata": { "dc": { "key": "69" }, "deletable": false, "editable": false, "run_control": { "frozen": true }, "tags": [ "context" ] }, "source": [ "## 10. Mapping the cosmetic items\n", "

Finally, it's show time! Let's see how the map we've made looks like. Each point on the plot corresponds to the cosmetic items. Then what do the axes mean here? The axes of a t-SNE plot aren't easily interpretable in terms of the original data. Like mentioned above, t-SNE is a visualizing technique to plot high-dimensional data in a low-dimensional space. Therefore, it's not desirable to interpret a t-SNE plot quantitatively.

\n", "

Instead, what we can get from this map is the distance between the points (which items are close and which are far apart). The closer the distance between the two items is, the more similar the composition they have. Therefore this enables us to compare the items without having any chemistry background.

" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "dc": { "key": "69" }, "tags": [ "sample_code" ] }, "outputs": [], "source": [ "# Plot the map\n", "output_file('./html/comparing_cosmetic.html')\n", "show(plot)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " Bokeh Plot\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "" ], "text/plain": [ "" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "HTML('./html/comparing_cosmetic.html')" ] }, { "cell_type": "markdown", "metadata": { "dc": { "key": "76" }, "deletable": false, "editable": false, "run_control": { "frozen": true }, "tags": [ "context" ] }, "source": [ "## 11. Comparing two products\n", "

Since there are so many cosmetics and so many ingredients, the plot doesn't have many super obvious patterns that simpler t-SNE plots can have (example). Our plot requires some digging to find insights, but that's okay!

\n", "

Say we enjoyed a specific product, there's an increased chance we'd enjoy another product that is similar in chemical composition. Say we enjoyed AmorePacific's Color Control Cushion Compact Broad Spectrum SPF 50+. We could find this product on the plot and see if a similar product(s) exist. And it turns out it does! If we look at the points furthest left on the plot, we see LANEIGE's BB Cushion Hydra Radiance SPF 50 essentially overlaps with the AmorePacific product. By looking at the ingredients, we can visually confirm the compositions of the products are similar (though it is difficult to do, which is why we did this analysis in the first place!), plus LANEIGE's version is $22 cheaper and actually has higher ratings.

\n", "

It's not perfect, but it's useful. In real life, we can actually use our little ingredient-based recommendation engine help us make educated cosmetic purchase choices.

" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "dc": { "key": "76" }, "tags": [ "sample_code" ] }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
LabelBrandNamePriceRankIngredientsCombinationDryNormalOilySensitiveXY
45MoisturizerAMOREPACIFICColor Control Cushion Compact Broad Spectrum S...604.0Phyllostachis Bambusoides Juice, Cyclopentasil...11111-5.693927-3.616628
\n", "
" ], "text/plain": [ " Label Brand \\\n", "45 Moisturizer AMOREPACIFIC \n", "\n", " Name Price Rank \\\n", "45 Color Control Cushion Compact Broad Spectrum S... 60 4.0 \n", "\n", " Ingredients Combination Dry \\\n", "45 Phyllostachis Bambusoides Juice, Cyclopentasil... 1 1 \n", "\n", " Normal Oily Sensitive X Y \n", "45 1 1 1 -5.693927 -3.616628 " ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "['Phyllostachis Bambusoides Juice, Cyclopentasiloxane, Cyclohexasiloxane, Peg-10 Dimethicone, Phenyl Trimethicone, Butylene Glycol, Butylene Glycol Dicaprylate/Dicaprate, Alcohol, Arbutin, Lauryl Peg-9 Polydimethylsiloxyethyl Dimethicone, Acrylates/Ethylhexyl Acrylate/Dimethicone Methacrylate Copolymer, Polyhydroxystearic Acid, Sodium Chloride, Polymethyl Methacrylate, Aluminium Hydroxide, Stearic Acid, Disteardimonium Hectorite, Triethoxycaprylylsilane, Ethylhexyl Palmitate, Lecithin, Isostearic Acid, Isopropyl Palmitate, Phenoxyethanol, Polyglyceryl-3 Polyricinoleate, Acrylates/Stearyl Acrylate/Dimethicone Methacrylate Copolymer, Dimethicone, Disodium Edta, Trimethylsiloxysilicate, Ethylhexyglycerin, Dimethicone/Vinyl Dimethicone Crosspolymer, Water, Silica, Camellia Japonica Seed Oil, Camillia Sinensis Leaf Extract, Caprylyl Glycol, 1,2-Hexanediol, Fragrance, Titanium Dioxide, Iron Oxides (Ci 77492, Ci 77491, Ci77499).']\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
LabelBrandNamePriceRankIngredientsCombinationDryNormalOilySensitiveXY
55MoisturizerLANEIGEBB Cushion Hydra Radiance SPF 50384.3Water, Cyclopentasiloxane, Zinc Oxide (CI 7794...11111-5.725039-3.636934
\n", "
" ], "text/plain": [ " Label Brand Name Price Rank \\\n", "55 Moisturizer LANEIGE BB Cushion Hydra Radiance SPF 50 38 4.3 \n", "\n", " Ingredients Combination Dry \\\n", "55 Water, Cyclopentasiloxane, Zinc Oxide (CI 7794... 1 1 \n", "\n", " Normal Oily Sensitive X Y \n", "55 1 1 1 -5.725039 -3.636934 " ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "['Water, Cyclopentasiloxane, Zinc Oxide (CI 77947), Ethylhexyl Methoxycinnamate, PEG-10 Dimethicone, Cyclohexasiloxane, Phenyl Trimethicone, Iron Oxides (CI 77492), Butylene Glycol Dicaprylate/Dicaprate, Niacinamide, Lauryl PEG-9 Polydimethylsiloxyethyl Dimethicone, Acrylates/Ethylhexyl Acrylate/Dimethicone Methacrylate Copolymer, Titanium Dioxide (CI 77891 , Iron Oxides (CI 77491), Butylene Glycol, Sodium Chloride, Iron Oxides (CI 77499), Aluminum Hydroxide, HDI/Trimethylol Hexyllactone Crosspolymer, Stearic Acid, Methyl Methacrylate Crosspolymer, Triethoxycaprylylsilane, Phenoxyethanol, Fragrance, Disteardimonium Hectorite, Caprylyl Glycol, Yeast Extract, Acrylates/Stearyl Acrylate/Dimethicone Methacrylate Copolymer, Dimethicone, Trimethylsiloxysilicate, Polysorbate 80, Disodium EDTA, Hydrogenated Lecithin, Dimethicone/Vinyl Dimethicone Crosspolymer, Mica (CI 77019), Silica, 1,2-Hexanediol, Polypropylsilsesquioxane, Chenopodium Quinoa Seed Extract, Magnesium Sulfate, Calcium Chloride, Camellia Sinensis Leaf Extract, Manganese Sulfate, Zinc Sulfate, Ascorbyl Glucoside.']\n" ] } ], "source": [ "# Print the ingredients of two similar cosmetics\n", "cosmetic_1 = moisturizers_dry[moisturizers_dry['Name'] == \"Color Control Cushion Compact Broad Spectrum SPF 50+\"]\n", "cosmetic_2 = moisturizers_dry[moisturizers_dry['Name'] == \"BB Cushion Hydra Radiance SPF 50\"]\n", "\n", "# Display each item's data and ingredients\n", "display(cosmetic_1)\n", "print(cosmetic_1.Ingredients.values)\n", "display(cosmetic_2)\n", "print(cosmetic_2.Ingredients.values)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.6" } }, "nbformat": 4, "nbformat_minor": 2 }