{ "cells": [ { "cell_type": "markdown", "metadata": { "cell_id": "db5e2cb5765640f7b3b0e782bd19b9fb", "deepnote_cell_height": 165.1875, "deepnote_cell_type": "markdown", "tags": [] }, "source": [ "# Rescaling data\n", "\n", "We're going to begin the *Machine Learning* portion of Math 10. The main goal will be to make predictions using data, but we'll start with a simpler topic, rescaling numerical data so that each numerical column has mean 0 and standard deviation 1." ] }, { "cell_type": "markdown", "metadata": { "cell_id": "0b5962483b98428786bf14491d2e81cd", "deepnote_cell_height": 252.578125, "deepnote_cell_type": "markdown", "tags": [] }, "source": [ "## Preparing the Spotify dataset\n", "\n", "* Import the Spotify dataset, specify `na_values=\" \"`, and drop the rows containing missing values.\n", "* We won't use all of the columns. Define a pandas DataFrame `df` which contains only the following columns from the Spotify dataset.\n", "\n", "```\n", "othercols = [\"Artist\", \"Song Name\", \"Week of Highest Charting\"]\n", "numcols = [\"Danceability\", \"Energy\", \"Speechiness\", \"Acousticness\", \"Valence\", \"Duration (ms)\"]\n", "```" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "cell_id": "c576e490e3464819b2da38d5b10da973", "deepnote_cell_height": 99, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 208, "execution_start": 1650657487592, "source_hash": "46e6bd77", "tags": [] }, "outputs": [], "source": [ "import pandas as pd\n", "import altair as alt" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "cell_id": "7587501dc050496484bb9ffd97f1ea61", "deepnote_cell_height": 81, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 24, "execution_start": 1650658254346, "source_hash": "e1cdfce5", "tags": [] }, "outputs": [], "source": [ "df = pd.read_csv(\"../data/spotify_dataset.csv\", na_values=\" \").dropna()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "cell_id": "928948d3c2034fd89445b7fdadc57f68", "deepnote_cell_height": 99, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 0, "execution_start": 1650657830973, "source_hash": "db11ec09", "tags": [] }, "outputs": [], "source": [ "othercols = [\"Artist\", \"Song Name\", \"Week of Highest Charting\"]\n", "numcols = [\"Danceability\", \"Energy\", \"Speechiness\", \"Acousticness\", \"Valence\", \"Duration (ms)\"]" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "cell_id": "44d7a39cb9384aee8dbc2aa1197a5dbb", "deepnote_cell_height": 600, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 44, "execution_start": 1650657877748, "source_hash": "7c528046", "tags": [] }, "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
DanceabilityEnergySpeechinessAcousticnessValenceDuration (ms)
00.7140.8000.05040.127000.589211560.0
10.5910.7640.04830.038300.478141806.0
20.5630.6640.15400.335000.688178147.0
30.8080.8970.03480.046900.591231041.0
40.7360.7040.06150.020300.894212000.0
.....................
15510.7620.7000.06940.002610.608209320.0
15520.5280.8700.08510.240000.714181930.0
15530.7650.5230.03000.184000.394217307.0
15540.8320.5500.05870.249000.881152784.0
15550.4480.6030.06400.433000.422221307.0
\n", "

1545 rows × 6 columns

\n", "
" ], "text/plain": [ " Danceability Energy Speechiness Acousticness Valence Duration (ms)\n", "0 0.714 0.800 0.0504 0.12700 0.589 211560.0\n", "1 0.591 0.764 0.0483 0.03830 0.478 141806.0\n", "2 0.563 0.664 0.1540 0.33500 0.688 178147.0\n", "3 0.808 0.897 0.0348 0.04690 0.591 231041.0\n", "4 0.736 0.704 0.0615 0.02030 0.894 212000.0\n", "... ... ... ... ... ... ...\n", "1551 0.762 0.700 0.0694 0.00261 0.608 209320.0\n", "1552 0.528 0.870 0.0851 0.24000 0.714 181930.0\n", "1553 0.765 0.523 0.0300 0.18400 0.394 217307.0\n", "1554 0.832 0.550 0.0587 0.24900 0.881 152784.0\n", "1555 0.448 0.603 0.0640 0.43300 0.422 221307.0\n", "\n", "[1545 rows x 6 columns]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[numcols]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "It's important to give a list of column names inside the square brackets. The following doesn't work because what's inside the square brackets is not a list." ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "cell_id": "d0a6c574dc5243fb80c6718a92716bce", "deepnote_cell_height": 253.390625, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 36, "execution_start": 1650657905716, "source_hash": "ac887d58", "tags": [] }, "outputs": [ { "ename": "KeyError", "evalue": "('Danceability', 'Energy', 'Speechiness', 'Acousticness', 'Valence', 'Duration (ms)')", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m~/miniconda3/envs/math10s22/lib/python3.7/site-packages/pandas/core/indexes/base.py\u001b[0m in \u001b[0;36mget_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m 3360\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 3361\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcasted_key\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3362\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/miniconda3/envs/math10s22/lib/python3.7/site-packages/pandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", "\u001b[0;32m~/miniconda3/envs/math10s22/lib/python3.7/site-packages/pandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", "\u001b[0;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n", "\u001b[0;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n", "\u001b[0;31mKeyError\u001b[0m: ('Danceability', 'Energy', 'Speechiness', 'Acousticness', 'Valence', 'Duration (ms)')", "\nThe above exception was the direct cause of the following exception:\n", "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m/var/folders/8j/gshrlmtn7dg4qtztj4d4t_w40000gn/T/ipykernel_60426/2983493298.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m df['Danceability',\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;34m'Energy'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;34m'Speechiness'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m'Acousticness'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;34m'Valence'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/miniconda3/envs/math10s22/lib/python3.7/site-packages/pandas/core/frame.py\u001b[0m in \u001b[0;36m__getitem__\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m 3456\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mnlevels\u001b[0m \u001b[0;34m>\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3457\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_getitem_multilevel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 3458\u001b[0;31m \u001b[0mindexer\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3459\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mis_integer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mindexer\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3460\u001b[0m \u001b[0mindexer\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mindexer\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/miniconda3/envs/math10s22/lib/python3.7/site-packages/pandas/core/indexes/base.py\u001b[0m in \u001b[0;36mget_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m 3361\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcasted_key\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3362\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 3363\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0merr\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3364\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3365\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mis_scalar\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0misna\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhasnans\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mKeyError\u001b[0m: ('Danceability', 'Energy', 'Speechiness', 'Acousticness', 'Valence', 'Duration (ms)')" ] } ], "source": [ "df['Danceability',\n", " 'Energy',\n", " 'Speechiness',\n", " 'Acousticness',\n", " 'Valence',\n", " 'Duration (ms)']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Adding an extra set of square brackets fixes the issue, because now what's inside the outer square brackets is a list." ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "cell_id": "f02e1e5bc2a64721a85599de6bf49a34", "deepnote_cell_height": 690, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 33, "execution_start": 1650657943703, "source_hash": "d941907e", "tags": [] }, "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
DanceabilityEnergySpeechinessAcousticnessValenceDuration (ms)
00.7140.8000.05040.127000.589211560.0
10.5910.7640.04830.038300.478141806.0
20.5630.6640.15400.335000.688178147.0
30.8080.8970.03480.046900.591231041.0
40.7360.7040.06150.020300.894212000.0
.....................
15510.7620.7000.06940.002610.608209320.0
15520.5280.8700.08510.240000.714181930.0
15530.7650.5230.03000.184000.394217307.0
15540.8320.5500.05870.249000.881152784.0
15550.4480.6030.06400.433000.422221307.0
\n", "

1545 rows × 6 columns

\n", "
" ], "text/plain": [ " Danceability Energy Speechiness Acousticness Valence Duration (ms)\n", "0 0.714 0.800 0.0504 0.12700 0.589 211560.0\n", "1 0.591 0.764 0.0483 0.03830 0.478 141806.0\n", "2 0.563 0.664 0.1540 0.33500 0.688 178147.0\n", "3 0.808 0.897 0.0348 0.04690 0.591 231041.0\n", "4 0.736 0.704 0.0615 0.02030 0.894 212000.0\n", "... ... ... ... ... ... ...\n", "1551 0.762 0.700 0.0694 0.00261 0.608 209320.0\n", "1552 0.528 0.870 0.0851 0.24000 0.714 181930.0\n", "1553 0.765 0.523 0.0300 0.18400 0.394 217307.0\n", "1554 0.832 0.550 0.0587 0.24900 0.881 152784.0\n", "1555 0.448 0.603 0.0640 0.43300 0.422 221307.0\n", "\n", "[1545 rows x 6 columns]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[['Danceability',\n", " 'Energy',\n", " 'Speechiness',\n", " 'Acousticness',\n", " 'Valence',\n", " 'Duration (ms)']]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can combine two lists using `+`." ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "cell_id": "58cf3a87bbbb434ebc248c92a22e0fb4", "deepnote_cell_height": 271.75, "deepnote_cell_type": "code", "deepnote_output_heights": [ 174.765625 ], "deepnote_to_be_reexecuted": false, "execution_millis": 7, "execution_start": 1650657985797, "source_hash": "c8e98fd6", "tags": [] }, "outputs": [ { "data": { "text/plain": [ "['Artist',\n", " 'Song Name',\n", " 'Week of Highest Charting',\n", " 'Danceability',\n", " 'Energy',\n", " 'Speechiness',\n", " 'Acousticness',\n", " 'Valence',\n", " 'Duration (ms)']" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "othercols+numcols" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "cell_id": "d2c0960425c94ddd9db88ba695104685", "deepnote_cell_height": 600, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 50, "execution_start": 1650658010585, "source_hash": "114e8bd9", "tags": [] }, "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", " \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", "
ArtistSong NameWeek of Highest ChartingDanceabilityEnergySpeechinessAcousticnessValenceDuration (ms)
0MåneskinBeggin'2021-07-23--2021-07-300.7140.8000.05040.127000.589211560.0
1The Kid LAROISTAY (with Justin Bieber)2021-07-23--2021-07-300.5910.7640.04830.038300.478141806.0
2Olivia Rodrigogood 4 u2021-06-25--2021-07-020.5630.6640.15400.335000.688178147.0
3Ed SheeranBad Habits2021-07-02--2021-07-090.8080.8970.03480.046900.591231041.0
4Lil Nas XINDUSTRY BABY (feat. Jack Harlow)2021-07-23--2021-07-300.7360.7040.06150.020300.894212000.0
..............................
1551Dua LipaNew Rules2019-12-27--2020-01-030.7620.7000.06940.002610.608209320.0
1552Jorge & MateusCheirosa - Ao Vivo2019-12-27--2020-01-030.5280.8700.08510.240000.714181930.0
1553Camila CabelloHavana (feat. Young Thug)2019-12-27--2020-01-030.7650.5230.03000.184000.394217307.0
1554Dadá Boladão, Tati Zaqui, OIKSurtada - Remix Brega Funk2019-12-27--2020-01-030.8320.5500.05870.249000.881152784.0
1555Taylor SwiftLover (Remix) [feat. Shawn Mendes]2019-12-27--2020-01-030.4480.6030.06400.433000.422221307.0
\n", "

1545 rows × 9 columns

\n", "
" ], "text/plain": [ " Artist Song Name \\\n", "0 Måneskin Beggin' \n", "1 The Kid LAROI STAY (with Justin Bieber) \n", "2 Olivia Rodrigo good 4 u \n", "3 Ed Sheeran Bad Habits \n", "4 Lil Nas X INDUSTRY BABY (feat. Jack Harlow) \n", "... ... ... \n", "1551 Dua Lipa New Rules \n", "1552 Jorge & Mateus Cheirosa - Ao Vivo \n", "1553 Camila Cabello Havana (feat. Young Thug) \n", "1554 Dadá Boladão, Tati Zaqui, OIK Surtada - Remix Brega Funk \n", "1555 Taylor Swift Lover (Remix) [feat. Shawn Mendes] \n", "\n", " Week of Highest Charting Danceability Energy Speechiness \\\n", "0 2021-07-23--2021-07-30 0.714 0.800 0.0504 \n", "1 2021-07-23--2021-07-30 0.591 0.764 0.0483 \n", "2 2021-06-25--2021-07-02 0.563 0.664 0.1540 \n", "3 2021-07-02--2021-07-09 0.808 0.897 0.0348 \n", "4 2021-07-23--2021-07-30 0.736 0.704 0.0615 \n", "... ... ... ... ... \n", "1551 2019-12-27--2020-01-03 0.762 0.700 0.0694 \n", "1552 2019-12-27--2020-01-03 0.528 0.870 0.0851 \n", "1553 2019-12-27--2020-01-03 0.765 0.523 0.0300 \n", "1554 2019-12-27--2020-01-03 0.832 0.550 0.0587 \n", "1555 2019-12-27--2020-01-03 0.448 0.603 0.0640 \n", "\n", " Acousticness Valence Duration (ms) \n", "0 0.12700 0.589 211560.0 \n", "1 0.03830 0.478 141806.0 \n", "2 0.33500 0.688 178147.0 \n", "3 0.04690 0.591 231041.0 \n", "4 0.02030 0.894 212000.0 \n", "... ... ... ... \n", "1551 0.00261 0.608 209320.0 \n", "1552 0.24000 0.714 181930.0 \n", "1553 0.18400 0.394 217307.0 \n", "1554 0.24900 0.881 152784.0 \n", "1555 0.43300 0.422 221307.0 \n", "\n", "[1545 rows x 9 columns]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[othercols+numcols]" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "cell_id": "855f04d0521d42b3b442158f35817ed4", "deepnote_cell_height": 81, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 4, "execution_start": 1650658266913, "source_hash": "b2cb1a04", "tags": [] }, "outputs": [], "source": [ "df = df[othercols+numcols].copy()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We now have the same number of rows but only 9 columns." ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "cell_id": "d504c0ed91a54d05b033ed04a5697d27", "deepnote_cell_height": 118.1875, "deepnote_cell_type": "code", "deepnote_output_heights": [ 21.1875 ], "deepnote_to_be_reexecuted": false, "execution_millis": 5, "execution_start": 1650658060636, "source_hash": "14f60b8f", "tags": [] }, "outputs": [ { "data": { "text/plain": [ "(1545, 9)" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.shape" ] }, { "cell_type": "markdown", "metadata": { "cell_id": "37b7f03272fa4f338b54f134a4760859", "deepnote_cell_height": 173.1875, "deepnote_cell_type": "markdown", "tags": [] }, "source": [ "## Copying a DataFrame\n", "\n", "* Define a new DataFrame `df1` to be `df`. (Do not use `copy`.)\n", "* Change the upper-leftmost entry in `df1`.\n", "* Look at `df`. What do you notice?" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "cell_id": "e6634c51875a46d99e1e063248aa5591", "deepnote_cell_height": 81, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 2, "execution_start": 1650658270613, "source_hash": "d94e4ce4", "tags": [] }, "outputs": [], "source": [ "df1 = df" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Subtle issue: `df1` and `df` are the exact same DataFrame (not just two separate but identical DataFrames). If you change one, you also change the other." ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "cell_id": "a952db51699d457e994cf915c9955fbf", "deepnote_cell_height": 118.1875, "deepnote_cell_type": "code", "deepnote_output_heights": [ 21.1875 ], "deepnote_to_be_reexecuted": false, "execution_millis": 494, "execution_start": 1650658370945, "source_hash": "fbc8429a", "tags": [] }, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df1 is df" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "cell_id": "388a6a6bf247437384e54e70d47ec535", "deepnote_cell_height": 81, "deepnote_cell_type": "code", "deepnote_output_heights": [ 21.1875 ], "deepnote_to_be_reexecuted": false, "execution_millis": 0, "execution_start": 1650658276655, "source_hash": "5e673059", "tags": [] }, "outputs": [], "source": [ "df1.iloc[0,0] = \"Christopher\"" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "cell_id": "c7411817ef7f4b2a9aaceb88142e39e4", "deepnote_cell_height": 395, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 35, "execution_start": 1650658282264, "source_hash": "ea6c9ba", "tags": [] }, "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", "
ArtistSong NameWeek of Highest ChartingDanceabilityEnergySpeechinessAcousticnessValenceDuration (ms)
0ChristopherBeggin'2021-07-23--2021-07-300.7140.8000.05040.12700.589211560.0
1The Kid LAROISTAY (with Justin Bieber)2021-07-23--2021-07-300.5910.7640.04830.03830.478141806.0
2Olivia Rodrigogood 4 u2021-06-25--2021-07-020.5630.6640.15400.33500.688178147.0
3Ed SheeranBad Habits2021-07-02--2021-07-090.8080.8970.03480.04690.591231041.0
4Lil Nas XINDUSTRY BABY (feat. Jack Harlow)2021-07-23--2021-07-300.7360.7040.06150.02030.894212000.0
\n", "
" ], "text/plain": [ " Artist Song Name Week of Highest Charting \\\n", "0 Christopher Beggin' 2021-07-23--2021-07-30 \n", "1 The Kid LAROI STAY (with Justin Bieber) 2021-07-23--2021-07-30 \n", "2 Olivia Rodrigo good 4 u 2021-06-25--2021-07-02 \n", "3 Ed Sheeran Bad Habits 2021-07-02--2021-07-09 \n", "4 Lil Nas X INDUSTRY BABY (feat. Jack Harlow) 2021-07-23--2021-07-30 \n", "\n", " Danceability Energy Speechiness Acousticness Valence Duration (ms) \n", "0 0.714 0.800 0.0504 0.1270 0.589 211560.0 \n", "1 0.591 0.764 0.0483 0.0383 0.478 141806.0 \n", "2 0.563 0.664 0.1540 0.3350 0.688 178147.0 \n", "3 0.808 0.897 0.0348 0.0469 0.591 231041.0 \n", "4 0.736 0.704 0.0615 0.0203 0.894 212000.0 " ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df1.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Notice how the top-left entry in `df` changed, even though we were using `df1`." ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "cell_id": "82af1573675c4d1f9cd9f4c039b700b8", "deepnote_cell_height": 395, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 14, "execution_start": 1650658297400, "source_hash": "c085b6ba", "tags": [] }, "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", "
ArtistSong NameWeek of Highest ChartingDanceabilityEnergySpeechinessAcousticnessValenceDuration (ms)
0ChristopherBeggin'2021-07-23--2021-07-300.7140.8000.05040.12700.589211560.0
1The Kid LAROISTAY (with Justin Bieber)2021-07-23--2021-07-300.5910.7640.04830.03830.478141806.0
2Olivia Rodrigogood 4 u2021-06-25--2021-07-020.5630.6640.15400.33500.688178147.0
3Ed SheeranBad Habits2021-07-02--2021-07-090.8080.8970.03480.04690.591231041.0
4Lil Nas XINDUSTRY BABY (feat. Jack Harlow)2021-07-23--2021-07-300.7360.7040.06150.02030.894212000.0
\n", "
" ], "text/plain": [ " Artist Song Name Week of Highest Charting \\\n", "0 Christopher Beggin' 2021-07-23--2021-07-30 \n", "1 The Kid LAROI STAY (with Justin Bieber) 2021-07-23--2021-07-30 \n", "2 Olivia Rodrigo good 4 u 2021-06-25--2021-07-02 \n", "3 Ed Sheeran Bad Habits 2021-07-02--2021-07-09 \n", "4 Lil Nas X INDUSTRY BABY (feat. Jack Harlow) 2021-07-23--2021-07-30 \n", "\n", " Danceability Energy Speechiness Acousticness Valence Duration (ms) \n", "0 0.714 0.800 0.0504 0.1270 0.589 211560.0 \n", "1 0.591 0.764 0.0483 0.0383 0.478 141806.0 \n", "2 0.563 0.664 0.1540 0.3350 0.688 178147.0 \n", "3 0.808 0.897 0.0348 0.0469 0.591 231041.0 \n", "4 0.736 0.704 0.0615 0.0203 0.894 212000.0 " ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This is not the same for something like an integer." ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "cell_id": "6f57e37ec9574afdbb3e51e87b32955e", "deepnote_cell_height": 81, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 3, "execution_start": 1650658320887, "source_hash": "2996127", "tags": [] }, "outputs": [], "source": [ "x = 10" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "cell_id": "f2f0acfab5c1471e8772f7aace2024ef", "deepnote_cell_height": 81, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 1, "execution_start": 1650658324084, "source_hash": "7055446d", "tags": [] }, "outputs": [], "source": [ "y = x" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "cell_id": "6f3e2dc6080b4a8c8e74d9e0551249bf", "deepnote_cell_height": 81, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 0, "execution_start": 1650658331569, "source_hash": "e70da293", "tags": [] }, "outputs": [], "source": [ "y = y+3" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "cell_id": "06b1c4a6670b4cf7b41850024bb91100", "deepnote_cell_height": 118.1875, "deepnote_cell_type": "code", "deepnote_output_heights": [ 21.1875 ], "deepnote_to_be_reexecuted": false, "execution_millis": 2, "execution_start": 1650658335636, "source_hash": "ce04b77e", "tags": [] }, "outputs": [ { "data": { "text/plain": [ "13" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "y" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this case, `x` does not get changed along with `y`." ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "cell_id": "7e364c0f8d1a49b19294927ca34f479d", "deepnote_cell_height": 118.1875, "deepnote_cell_type": "code", "deepnote_output_heights": [ 21.1875 ], "deepnote_to_be_reexecuted": false, "execution_millis": 6, "execution_start": 1650658344167, "source_hash": "577d5527", "tags": [] }, "outputs": [ { "data": { "text/plain": [ "10" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " This is a subtle issue and don't worry if you find it confusing. The most important thing is to watch for subtle errors when working with multiple DataFrames." ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "cell_id": "5c913622bf1b401e953d27da885dd6d2", "deepnote_cell_height": 81, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 0, "execution_start": 1650658397537, "source_hash": "89a087", "tags": [] }, "outputs": [], "source": [ "df1 = df.copy()" ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "cell_id": "2ba3d53b5f69496d8c324d6365827542", "deepnote_cell_height": 81, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 4, "execution_start": 1650658410669, "source_hash": "89d78a5e", "tags": [] }, "outputs": [], "source": [ "df1.iloc[0,0] = \"Math 10 Math 10\"" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "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", "
ArtistSong NameWeek of Highest ChartingDanceabilityEnergySpeechinessAcousticnessValenceDuration (ms)
0Math 10 Math 10Beggin'2021-07-23--2021-07-300.7140.8000.05040.12700.589211560.0
1The Kid LAROISTAY (with Justin Bieber)2021-07-23--2021-07-300.5910.7640.04830.03830.478141806.0
2Olivia Rodrigogood 4 u2021-06-25--2021-07-020.5630.6640.15400.33500.688178147.0
3Ed SheeranBad Habits2021-07-02--2021-07-090.8080.8970.03480.04690.591231041.0
4Lil Nas XINDUSTRY BABY (feat. Jack Harlow)2021-07-23--2021-07-300.7360.7040.06150.02030.894212000.0
\n", "
" ], "text/plain": [ " Artist Song Name \\\n", "0 Math 10 Math 10 Beggin' \n", "1 The Kid LAROI STAY (with Justin Bieber) \n", "2 Olivia Rodrigo good 4 u \n", "3 Ed Sheeran Bad Habits \n", "4 Lil Nas X INDUSTRY BABY (feat. Jack Harlow) \n", "\n", " Week of Highest Charting Danceability Energy Speechiness Acousticness \\\n", "0 2021-07-23--2021-07-30 0.714 0.800 0.0504 0.1270 \n", "1 2021-07-23--2021-07-30 0.591 0.764 0.0483 0.0383 \n", "2 2021-06-25--2021-07-02 0.563 0.664 0.1540 0.3350 \n", "3 2021-07-02--2021-07-09 0.808 0.897 0.0348 0.0469 \n", "4 2021-07-23--2021-07-30 0.736 0.704 0.0615 0.0203 \n", "\n", " Valence Duration (ms) \n", "0 0.589 211560.0 \n", "1 0.478 141806.0 \n", "2 0.688 178147.0 \n", "3 0.591 231041.0 \n", "4 0.894 212000.0 " ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df1.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this case, changing `df1` does not change `df`, because we used `.copy()`." ] }, { "cell_type": "code", "execution_count": 24, "metadata": { "cell_id": "817617fcc2cd4d75b72b565cf8f080c4", "deepnote_cell_height": 600, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 53, "execution_start": 1650658413036, "source_hash": "f804c160", "tags": [] }, "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", "
ArtistSong NameWeek of Highest ChartingDanceabilityEnergySpeechinessAcousticnessValenceDuration (ms)
0ChristopherBeggin'2021-07-23--2021-07-300.7140.8000.05040.12700.589211560.0
1The Kid LAROISTAY (with Justin Bieber)2021-07-23--2021-07-300.5910.7640.04830.03830.478141806.0
2Olivia Rodrigogood 4 u2021-06-25--2021-07-020.5630.6640.15400.33500.688178147.0
3Ed SheeranBad Habits2021-07-02--2021-07-090.8080.8970.03480.04690.591231041.0
4Lil Nas XINDUSTRY BABY (feat. Jack Harlow)2021-07-23--2021-07-300.7360.7040.06150.02030.894212000.0
\n", "
" ], "text/plain": [ " Artist Song Name Week of Highest Charting \\\n", "0 Christopher Beggin' 2021-07-23--2021-07-30 \n", "1 The Kid LAROI STAY (with Justin Bieber) 2021-07-23--2021-07-30 \n", "2 Olivia Rodrigo good 4 u 2021-06-25--2021-07-02 \n", "3 Ed Sheeran Bad Habits 2021-07-02--2021-07-09 \n", "4 Lil Nas X INDUSTRY BABY (feat. Jack Harlow) 2021-07-23--2021-07-30 \n", "\n", " Danceability Energy Speechiness Acousticness Valence Duration (ms) \n", "0 0.714 0.800 0.0504 0.1270 0.589 211560.0 \n", "1 0.591 0.764 0.0483 0.0383 0.478 141806.0 \n", "2 0.563 0.664 0.1540 0.3350 0.688 178147.0 \n", "3 0.808 0.897 0.0348 0.0469 0.591 231041.0 \n", "4 0.736 0.704 0.0615 0.0203 0.894 212000.0 " ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's get back to our original DataFrame." ] }, { "cell_type": "code", "execution_count": 25, "metadata": { "cell_id": "4fdaeb42d96640dc94d8d641e4dd5f14", "deepnote_cell_height": 81, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 3, "execution_start": 1650658534481, "source_hash": "4ad62dcc", "tags": [] }, "outputs": [], "source": [ "df.iloc[0,0] = \"Måneskin\"" ] }, { "cell_type": "markdown", "metadata": { "cell_id": "bbf4d61ae4d946bb8926fe1eaba5bf4a", "deepnote_cell_height": 173.1875, "deepnote_cell_type": "markdown", "tags": [] }, "source": [ "## Rescaling 1: using a for loop\n", "\n", "* Make a copy of `df` called `df1`.\n", "* Using a for loop, for each column in `numcols`, rescale `df1` so that column has mean 0.\n", "* Check your answer using `mean` with the `axis` keyword argument." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We could also skip the `axis=0` part, but it's good to include it to remember that `axis=0` means to compute the `mean` of each column, one at a time." ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "cell_id": "99af3b4f3a4e473db50f35e067e6c4de", "deepnote_cell_height": 233.375, "deepnote_cell_type": "code", "deepnote_output_heights": [ 136.375 ], "deepnote_to_be_reexecuted": false, "execution_millis": 8, "execution_start": 1650658598706, "source_hash": "40438b43", "tags": [] }, "outputs": [ { "data": { "text/plain": [ "Danceability 0.689997\n", "Energy 0.633495\n", "Speechiness 0.123656\n", "Acousticness 0.248695\n", "Valence 0.514704\n", "Duration (ms) 197940.816828\n", "dtype: float64" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[numcols].mean(axis=0)" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [], "source": [ "c = \"Energy\"" ] }, { "cell_type": "code", "execution_count": 28, "metadata": { "cell_id": "e5fac454eefd459fbd493a1445439418", "deepnote_cell_height": 118.1875, "deepnote_cell_type": "code", "deepnote_output_heights": [ 21.1875 ], "deepnote_to_be_reexecuted": false, "execution_millis": 12, "execution_start": 1650658872792, "source_hash": "45029b20", "tags": [] }, "outputs": [ { "data": { "text/plain": [ "0.633495145631068" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[c].mean()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here we are rescaling each of the numeric columns." ] }, { "cell_type": "code", "execution_count": 29, "metadata": { "cell_id": "045cb4dd6ad54983b4da02479625f13a", "deepnote_cell_height": 99, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 0, "execution_start": 1650658968312, "source_hash": "ea95c334", "tags": [] }, "outputs": [], "source": [ "for c in numcols:\n", " df1[c] = df1[c] - df1[c].mean()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Notice that these numbers in the following output are very close to zero. This is probably as close as we can get, due to numerical precision issues." ] }, { "cell_type": "code", "execution_count": 30, "metadata": { "cell_id": "f35f5001280a40d8aa0577668265cfd9", "deepnote_cell_height": 233.375, "deepnote_cell_type": "code", "deepnote_output_heights": [ 136.375 ], "deepnote_to_be_reexecuted": false, "execution_millis": 11, "execution_start": 1650659054881, "source_hash": "6c2b4fa0", "tags": [] }, "outputs": [ { "data": { "text/plain": [ "Danceability -8.738066e-17\n", "Energy -5.058880e-17\n", "Speechiness 1.149746e-18\n", "Acousticness 3.219287e-17\n", "Valence 1.034771e-17\n", "Duration (ms) -6.630776e-12\n", "dtype: float64" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df1[numcols].mean(axis=0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here were the average values from the original DataFrame." ] }, { "cell_type": "code", "execution_count": 31, "metadata": { "cell_id": "a226e2a250b7480fab9e2e28e897300c", "deepnote_cell_height": 233.375, "deepnote_cell_type": "code", "deepnote_output_heights": [ 136.375 ], "deepnote_to_be_reexecuted": false, "execution_millis": 4, "execution_start": 1650659058321, "source_hash": "b573a80f", "tags": [] }, "outputs": [ { "data": { "text/plain": [ "Danceability 0.689997\n", "Energy 0.633495\n", "Speechiness 0.123656\n", "Acousticness 0.248695\n", "Valence 0.514704\n", "Duration (ms) 197940.816828\n", "dtype: float64" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[numcols].mean(axis=0)" ] }, { "cell_type": "markdown", "metadata": { "cell_id": "7f989376b5e14b44ad539e6ae7811a43", "deepnote_cell_height": 170.1875, "deepnote_cell_type": "markdown", "tags": [] }, "source": [ "## Rescaling 2: using apply\n", "* Make a copy of `df` called `df2`.\n", "* Using the `apply` method, rescale each column in numcols so it has mean 0. Specify the `axis` keyword argument so that `apply` operates on each column, one at a time." ] }, { "cell_type": "code", "execution_count": 32, "metadata": { "cell_id": "7859e52e59884d4e87c52ad9079e1952", "deepnote_cell_height": 81, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 0, "execution_start": 1650659200187, "source_hash": "f91a71af", "tags": [] }, "outputs": [], "source": [ "df2 = df.copy()" ] }, { "cell_type": "code", "execution_count": 33, "metadata": { "cell_id": "bdd13bfdf24f4a27a9f9463d7d84a13b", "deepnote_cell_height": 118.1875, "deepnote_cell_type": "code", "deepnote_output_heights": [ 21.1875 ], "deepnote_to_be_reexecuted": false, "execution_millis": 7, "execution_start": 1650659208935, "source_hash": "48de49ab", "tags": [] }, "outputs": [ { "data": { "text/plain": [ "(1545, 9)" ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df2.shape" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here is an example of applying the `len` function to each column. All of these columns have length 1545. Specifying `axis=0` indicates that we are plugging in the columns, one at a time, not plugging in the rows." ] }, { "cell_type": "code", "execution_count": 34, "metadata": { "cell_id": "d8bf97a2431b485a8bd7334ba802cc58", "deepnote_cell_height": 290.9375, "deepnote_cell_type": "code", "deepnote_output_heights": [ 193.953125 ], "deepnote_to_be_reexecuted": false, "execution_millis": 8, "execution_start": 1650659241038, "source_hash": "9ef00d79", "tags": [] }, "outputs": [ { "data": { "text/plain": [ "Artist 1545\n", "Song Name 1545\n", "Week of Highest Charting 1545\n", "Danceability 1545\n", "Energy 1545\n", "Speechiness 1545\n", "Acousticness 1545\n", "Valence 1545\n", "Duration (ms) 1545\n", "dtype: int64" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df2.apply(len, axis=0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here is an example of getting the 0-th entry from each column." ] }, { "cell_type": "code", "execution_count": 35, "metadata": { "cell_id": "ba16370e85ac4865b21e32a2291672f5", "deepnote_cell_height": 290.9375, "deepnote_cell_type": "code", "deepnote_output_heights": [ 193.953125 ], "deepnote_to_be_reexecuted": false, "execution_millis": 9, "execution_start": 1650659290733, "source_hash": "d0e9e1b9", "tags": [] }, "outputs": [ { "data": { "text/plain": [ "Artist Måneskin\n", "Song Name Beggin'\n", "Week of Highest Charting 2021-07-23--2021-07-30\n", "Danceability 0.714\n", "Energy 0.8\n", "Speechiness 0.0504\n", "Acousticness 0.127\n", "Valence 0.589\n", "Duration (ms) 211560.0\n", "dtype: object" ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df2.apply(lambda s: s.iloc[0], axis=0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "What we actually care about is subtracting the mean. Here is an example." ] }, { "cell_type": "code", "execution_count": 36, "metadata": { "cell_id": "f177bff94e4845f4a0005605fdae003c", "deepnote_cell_height": 81, "deepnote_cell_type": "code", "deepnote_output_heights": [ 232.34375 ], "deepnote_to_be_reexecuted": false, "execution_millis": 4, "execution_start": 1650659349460, "source_hash": "67feedb3", "tags": [] }, "outputs": [], "source": [ "s = df[\"Energy\"]" ] }, { "cell_type": "code", "execution_count": 37, "metadata": { "cell_id": "47e3765a561a47bb9ccb1fada0635170", "deepnote_cell_height": 329.34375, "deepnote_cell_type": "code", "deepnote_output_heights": [ 232.34375 ], "deepnote_to_be_reexecuted": false, "execution_millis": 6, "execution_start": 1650659373786, "source_hash": "346db727", "tags": [] }, "outputs": [ { "data": { "text/plain": [ "0 0.166505\n", "1 0.130505\n", "2 0.030505\n", "3 0.263505\n", "4 0.070505\n", " ... \n", "1551 0.066505\n", "1552 0.236505\n", "1553 -0.110495\n", "1554 -0.083495\n", "1555 -0.030495\n", "Name: Energy, Length: 1545, dtype: float64" ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s-s.mean()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we can use that formula for each column. But notice that it only makes sense for numeric columns." ] }, { "cell_type": "code", "execution_count": 38, "metadata": { "cell_id": "a6d4804a70a64fa393fae45f21100d7d", "deepnote_cell_height": 4655.34375, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 440, "execution_start": 1650659385098, "source_hash": "9735f306", "tags": [] }, "outputs": [ { "ename": "TypeError", "evalue": "Could not convert MåneskinThe Kid LAROIOlivia RodrigoEd SheeranLil Nas XLil Nas XDoja CatRauw AlejandroBad BunnyMåneskinDua LipaJ Balvin, Maria BecerraBTSJustin BieberBTSOlivia RodrigoOlivia RodrigoThe WeekndNio Garcia, J Balvin, Bad BunnyDoja CatMora, Bad Bunny, SechDoja CatOlivia RodrigoGlass AnimalsThe WeekndOlivia RodrigoFarrukoPost MaloneRiton, NightcrawlersMasked WolfBruno Mars, Anderson .Paak, Silk SonicCamila CabelloOlivia RodrigoSebastian Yatra, Myke TowersHarry StylesPolo GDoja Cat, The WeekndSech, Jhay CortezBad Bunny, Jhay CortezTINI, Maria BecerraOlivia RodrigoJ Balvin, KAROL G, Nicky Jam, Crissin, Totoy El Frio, Natan & ShanderBTSTiëstoGalantis24kGoldnTiago PZK, LIT killahWisin, Jhay Cortez, Anuel AA, Los Legendarios, Myke TowersBella PoarchBizarrap, Nicky JamMarc Seguí, Rauw Alejandro, Pol GranchBillie EilishMajestic, Boney M.MarshmelloSurf CurseJoão GomesRauw Alejandro, Mr. NaisgaiMaroon 5OneRepublicMegan Thee StallionATB, Topic, A7SOlivia RodrigoThe WeekndGiveonDua LipaTrinidad CardonaThe NeighbourhoodMalumaLewis CapaldiSmileySleepy HallowKAROL G, Mariah AngeliqJustin Quiles, Chimbala, Zion & LennoxShouseMåneskinKali UchisGera MX, Christian NodalLos Legendarios, Wisin, Jhay CortezTones And IThe Kid LAROIDrakeBo BurnhamDua LipaTravis Scott, HVMEJoel CorryJoel Corry, RAYE, David GuettaJustin Wellington, Small JamBelly, The Weeknd, Young ThugDuncan LaurenceMora, Jhay CortezAriana GrandePost MaloneRAF Camora, Bonez MCNatti Natasha, Becky GJ Balvin, SkrillexDoja CatWILLOWDaveLewis CapaldiDua LipaMadison BeerBANDIDOImagine DragonsInternet MoneyBruno MarsSAINt JHNSechBecky G, El AlfaIngrataxBillie EilishPost Malone, Swae LeedhruvDoja CatCalvin HarrisLuan SantanaEd SheeranShawn Mendes, Camila CabelloJustin BieberEd SheeranMYA, TINI, DukiBad Bunny, ROSALÍADaBabyConan GrayTate McRaeAviciiVance JoyNirvanaOlivia RodrigoThe NeighbourhoodJoão GomesTrippie ReddMaroon 5Tom OdellJamie MillerHozierTom GrennanGusttavo LimaCardi BMalumaKhalidQueenMyke Towers, JuhnMEDUZATravis ScottOfenbachCamilo, Shawn MendesLady Gaga, Bradley CooperCochise, $NOTMari FernandezOneRepublicColdplayEmilia, DukiJoão Gomes, Vitor FernandesAviciiMatheus Fernandes, DilsinhoVegedreamPop SmokeAURORADaBabyDaBabyJuice WRLDLil Tjay, 6LACKBillie EilishP!nk, Willow Sage HartPop SmokeOlivia RodrigoCardi BThe KillersThe PoliceFleetwood MacJames ArthurNormaniPop SmokePop SmokePowfu, beabadoobeeAnne-Marie, Niall HoranQueenDrake, WizKid, KylaHarry StylesSarah CothranWalker HayesRauw AlejandroJohn LegendPolo GPop SmokeSaweetieThe WeekndSZAAnne-Marie, Little MixBad BunnyAriana GrandeBlxst, TygaMC Zaquin, MC RickTopic, A7SLuísa SonzaRoddy RicchDaveEminemPop SmokePop SmokeTrippie Redd, Lil Uzi VertPop SmokePop SmokeKSIPop SmokePop SmokeTyler, The CreatorPashanimTion Wayne, Russ MillionsPop SmokeNio Garcia, Flow La MovieBLANCO, Sfera EbbastaRegardBillie EilishJohn MayerImagine DragonsMc Davi, Mc Pedrinho, Mc Don JuanInternet MoneyImagine DragonsDua LipaBTSSechSelena GomezBasOlivia RodrigoIsrael & Rodolffo, Wesley SafadãoTWICEBIAKane Brown, blackbearAlex Rose, Rauw AlejandroDj Guuga, DJ IvisMaluma, Beéle, Rauw Alejandro, Mambo Kingz, DJ Luian, DarellRauw AlejandroThe Chainsmokers, HalseyOasisBrent FaiyazDoja CatBig Red MachineTyler, The CreatorBo BurnhamDJ KhaledStarBoi3LordeBillie EilishShirin DavidCJIsrael & RodolffoMiley CyrusGym Class HeroesRauw Alejandro, Anuel AAsangiovanniBizarrap, Eladio CarrionArctic MonkeysTyler, The CreatorTyler, The CreatorTyler, The CreatorTyler, The CreatorTyler, The CreatorTyler, The CreatorTyler, The CreatorTyler, The CreatorTyler, The CreatorDoja CatTyler, The CreatorTyler, The CreatorDoja CatMigosDoja CatDoja CatFedez, Achille LauroJ Balvin, Dua Lipa, Bad BunnyJawsh 685, Jason DeruloCrissin, Totoy El Frio, Natan & ShanderBozaTate McRae, KhalidSoso ManessJ. ColeJ. ColeXXXTENTACIONPolo GRoddy RicchNathan EvansMacklemore & Ryan LewisJustin BieberMachine Gun KellyBruno MarsTravis ScottDua LipaDrakeMartin GarrixRochy RD, Myke Towers, Nicki NicoleLinkin ParkJ. ColeTravis ScottThe Chainsmokers, ColdplayRegard, Troye Sivan, Tate McRaeMigosPolo GPolo GMaroon 5MigosAva MaxMigosBlack Eyed Peas, ShakiraPolo GMigosBillie EilishBad BunnyMC Kevin o ChrisColdplayLil Nas XPolo GLady GagaLil Baby, Lil DurkJohn MayerLil Baby, Lil DurkTOMORROW X TOGETHER, SeoriJ. ColeLil TeccaYoung Stoner Life, Young Thug, GunnaManuel Turizo, Rauw Alejandro, Myke TowersHarry StylesMåneskinKAROL GAshnikkoEminemAlok, Mc Don Juan, Dj GBRJuice WRLDJuice WRLDBTSMalu, DJ Lucas BeatEminemLil MoseyGotye, KimbraJustin BieberMc Poze do Rodo, Neo Beats, MainstreetJ. ColeBTSBTSBarbara PraviTwenty One PilotsTwenty One PilotsJ. ColeNicki MinajBlind ChannelGo_AITZYJ. ColeDrakeJoyner Lucas, Lil BabyBeach BunnyGjon's TearsLil TjayDreamDaði FreyrTwenty One PilotsJ. ColeJ. ColeJ. ColeJ. ColeJ. ColeJ. ColeThe Kid LAROIBizarrap, Snow Tha ProductNio Garcia, Casper Magico, Ozuna, Wisin & Yandel, Myke Towers, Flow La MovieMARINAHarry StylesMyke TowersMilly, Farruko, Nio Garcia, Jay Wheeler, AmenazzyDaddy YankeeJustin BieberGym Class HeroesJP SaxeDJ KhaledRuss Millions, Tion WayneBillie EilishDon ToliverBizarrap, L-GanteLil Nas XPink Sweat$Future187 Strassenbande, Bonez MC, FrauenarztJuice WRLDNicky Jam, Romeo SantosRaí Saia RodadaCamilo, Evaluna MontanerJuice WRLDJuice WRLDJorge & MateusElyOttoBaby KeemMachine Gun KellyDJ KhaledDJ KhaledAnittaROSÉTaylor SwiftBillie EilishJ Balvin, KhalidDemi LovatoPooh ShiestyLil TjayWisin, Myke Towers, Los LegendariosJustin BieberH.E.R.HVMERitt MomneyDiego & Victor Hugo, Bruno & MarroneJames ArthurShawn MendesThe WeekndXXXTENTACIONMimi WebbblackbearBruno MarsKAROL G, Anuel AA, J BalvinTwenty One PilotsYoung Stoner Life, Young Thug, GunnaYoung Stoner Life, Young Thug, GunnaTaylor SwiftWesley Safadão, Os Barões Da PisadinhaOs Barões Da PisadinhaTaylor SwiftArctic MonkeysEd SheeranJ Balvin, Bad BunnyTaylor SwiftTaylor SwiftDMXTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftDMXTaylor SwiftTaylor SwiftTaylor SwiftSebastian Yatra, GuaynaaSech, Daddy Yankee, J Balvin, ROSALÍA, FarrukoTaylor SwiftTaylor SwiftKHEA, DukiDemi LovatoROSÉSam Fischer, Demi LovatoPop SmokeKevin Roldan, Bryant Myers, LyannoJason DeruloJustin BieberAriana GrandeMother MotherDJ IvisRusherking, KHEA, Duki, Maria Becerra, LIT killah, Tiago PZKMaroon 5, Wiz KhalifaJustin BieberJustin BieberJack Harlowa-haCamilo, El AlfaJ BalvinJustin BieberJustin BieberKAROL G, Nicki MinajOzuna, J Balvin, Chencho CorleoneJustin BieberZoe WeesDrakeDJ Ivis, Tarcísio do AcordeonJason Derulo, NukaJustin BieberThe Weeknd, Daft PunkFarrukoHugo & GuilhermeJustin BieberJustin BieberLana Del ReyNicky Jam, Myke TowersLana Del ReyMaluma, Lenny TavárezCamiloCamiloHippie SabotageJustin QuilesSelena GomezKSIDJ SnakeSiaMachine Gun KellyJay Wheeler, DJ Nelson, Myke TowersRobin SchulzDoja CatXXXTENTACIONTame ImpalaThe Weeknd, Daft PunkPop SmokeBANNERSPamungkasBLACKPINKNF, HopsinMadamePop SmokeJuice WRLDFrancesca Michielin, FedezAnuel AA, OzunaBooba, JSXLil BabyLele PonsOfenbach, QuarterheadLil PeepBØRNSConan GrayPost MaloneAriana GrandeC. Tangana, Niño de Elche, La HúngaraThe Kid LAROIJustin QuilesArizona ZervasPost MaloneC. Tangana, Ed MaverickHalseyBad BunnyJustin BieberClairoEd SheeranBausa, Apache 207NFShawn MendesSabrina CarpenterJack HarlowSara KaysJason Derulo, Maroon 5Tones And IOzuna, CamiloAriana GrandeEd SheeranKAROL GBizarrap, Nathy PelusoMaluma, The WeekndRauw AlejandroTarcísio do AcordeonXXXTENTACIONEd SheeranDrakeThe WeekndSurf MesaOasisXXXTENTACIONJuice WRLDBillie EilishSia, David GuettaThe Weekndbenny blancoThe WeekndMiley CyrusMartin GarrixBring Me The HorizonMalumaKawe, Mc Lele JPThe WeekndAriana GrandeDean LewisMegan Thee StallionJerry DiKASIMIR1441, badmómzjay, WILDBWOYSBrent Faiyaz, DJ DahiZAYNOlivia RodrigoAshnikkoMorgan WallenNio Garcia, Anuel AA, Myke Towers, Brray, JuankaAnuel AA, OzunaMigrantes, AlicoMorgan WallenSelena GomezJack HarlowSam Smith347aidanRauw Alejandro, J BalvinTaylor SwiftChris Brown, Young ThugJuice WRLD, The Kid LAROIAnne-Marie, KSI, Digital Farm AnimalsLuísa Sonza, Pabllo Vittar, AnittaErica BanksAva MaxBLACKPINKOzunaFousheéMorgan WallenMorgan WallenMorgan WallenBad BunnySech, J BalvinPop SmokeMorgan WallenMorgan WallenOs Barões Da PisadinhaBLACKPINKMarshmelloDua Lipa, AngèleApache 207Taylor SwiftSurfacesPetter Ferraz, Menor NicoMarshmello, BastilleQueenJ BalvinOs Barões Da Pisadinha, Xand AviãoKid CudiMEDUZA, Becky Hill, GoodboysTWICECORPSE, Savage Ga$pMariah CareyWham!Ariana GrandeBrenda LeeBobby HelmsMichael BubléAndy WilliamsKelly ClarksonJosé FelicianoDean MartinFrank SinatraJustin BieberThe RonettesBand AidPaul McCartneyMichael BubléJohn Lennon, Yoko OnoNat King ColeBing Crosby, Ken Darby Singers, John Scott Trotter & His OrchestraPlayboi CartiBurl IvesThe PoguesShakin' StevensElvis PresleyChuck BerryThe Jackson 5Kylie MinoguePerry Como, The Fontane SistersDarlene LoveElton JohnKid CudiJonas EsticadoJorge & MateusDaryl Hall & John OatesColdplaySam SmithSiaBritney SpearsBrett EldredgeJonas BrothersAva MaxGwen StefaniEminemNat King ColeMichael BubléIdina MenzelTaylor SwiftThe Jackson 5Eartha Kitt, Henri Rene & His OrchestraMykola Dmytrovych Leontovych, John WilliamsTaylor SwiftStevie WonderShawn MendesDean MartinBruce SpringsteenLeona LewisThe Beach BoysLiam PayneMeghan TrainorDean MartinFrank SinatraFrank SinatraMariah CareyBing CrosbyPentatonixDonny HathawayTony BennettTaylor SwiftKaty Perry*NSYNCTaylor SwiftEaglesMeghan TrainorTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftKid CudiKid CudiKid CudiKid CudiKid CudiKid CudiKid CudiBad BunnyKid CudiKid CudiTaylor SwiftJuice WRLDShawn MendesThe WeekndTory Lanez, Jack HarlowBad BunnyLil BabyMiley CyrusBTSsalem ileseBad Bunny, Jowell & Randy, Ñengo FlowBad BunnyThe Kid LAROIStudio Killers24kGoldnBad BunnyBad BunnyBad BunnyBad BunnyBad Bunny, ABRABad BunnyBad BunnyPaul McCartneyBTSBTSBTSBTSMiley CyrusTrio VegabajeñoMiley CyrusJhay Cortez, Bad BunnyBTSSfera EbbastaClean Bandit, MabelChristian Nodal, Ángela AguilarSfera EbbastaMaster KGSfera EbbastaAya NakamuraThe Kid LAROIJuice WRLDBLACKPINKJawsh 685, Jason DeruloJustin TimberlakeSfera Ebbasta21 Savage, Metro BoominWallowsDan + ShayVedoManuel TurizoStaySolidRockyFuture, Lil Uzi VertKane BrownK/DA, Madison Beer, (G)I-DLE, Lexie Liu, Jaira Burns, Seraphine, League of LegendsRauw AlejandroFuture, Lil Uzi VertOctavian, SkeptaAriana GrandeTy Dolla $ignLittle MixMAXFuture, Lil Uzi VertNelly Furtado, TimbalandDJ KhaledAriana GrandeLabrinthAnuel AA, Bad BunnyKinaDDGLuke CombsJojiDaddy Yankee, Anuel AA, Kendo KaponiBillie EilishCali Y El Dandee, Danna PaolaAriana GrandeAriana GrandeAriana GrandeThe Kid LAROIKHEAMalumaOzuna, KAROL G, Myke Towers21 Savage, Metro BoominPop SmokeAriana GrandeAriana GrandeEd SheeranCamiloDon ToliverJ BalvinAriana GrandeAriana GrandeAriana GrandeMichael JacksonSam SmithBonez MCSam SmithAC/DCAnittaMoney ManSechTravis ScottBLACKPINKBig SeanAriana GrandeBlack Eyed Peas, Ozuna, J. Rey SoulLauv, Conan GrayMarshmello, Demi LovatoTHE SCOTTS, Travis Scott, Kid CudiTrueno, Bizarrap, Taiu, TATOOLPassengerMelanie MartinezKygo, OneRepublicAdeleAli GatieCurtis WatersBLACKPINKG-Eazy13 Organisé, SCH, Kofs, Jul, Naps, Soso Maness, Elams, Solda, HouariBLACKPINKBebe RexhaROSALÍACamiloBad BunnyLana Del ReyGunnaRauw Alejandro, Dalex, Lenny TavárezNoah CyrusLewis CapaldiBLACKPINKBENEE, Gus Dapperton21 Savage, Metro BoominZAYNMachine Gun KellyNiackFeid, J Balvin, Justin QuilesChris Brown21 Savage, Metro Boomin21 Savage, Metro Boomin21 Savage, Metro BoominBryson Tiller21 Savage, Metro Boomin21 Savage, Metro Boomin21 Savage, Metro BoominInternet MoneyJoji21 Savage, Metro BoominWhoHeem21 Savage, Metro Boomin21 Savage, Metro BoominJojiJojiJoji, DiploPolo GMachine Gun KellyJojiJojiJojiBea MillerSaweetieJojiJoji, BENEECalvin HarrisJuice WRLD, Polo GMachine Gun KellyHarry NachJack HarlowKendrick Lamar, Jay RockInternet Money, DiploEarth, Wind & FireRegard, RAYEPolo GDamso, HamzaDamsoTaylor SwiftJuice WRLDJuice WRLDLil TeccaDrake6ix9ineDua LipaKygo, Donna SummerAva MaxAva MaxOzuna, Doja Cat, SiaSZA, The Neptunes, Pharrell Williams, Ty Dolla $ignMaroon 5MatuêBonez MCAlex Rose, Rafa PabönLil BabyBonez MC, MaxwellMiley CyrusDoja CatHeadie OneNeaBeyoncé, Megan Thee StallionBig SeanSaweetieITZYTravis ScottMalumaRobin Schulz, WesK/DA, (G)I-DLE, Wolftyla, Bea Miller, League of LegendsMc Zaac, Anitta, TygaPeach Tree RascalsTaylor SwiftBlack Eyed Peas, J BalvinKitschKrieg, Jamule, SFRKygo, Tina TurnerKaty PerryConkarahCordaeJACKBOYS, Travis ScottJowell & Randy, J BalvinAnuel AALady GagaRod WaveJuice WRLDJustin Quiles, Daddy Yankee, El AlfaInternet Money, Gunna, Don Toliver, NAVCapital Bra, CroBTSSam SmithJuice WRLDFeid, Justin QuilesBausa, JujuTaylor SwiftblackbearMustardBTSJason Mraz5 Seconds of SummerTaylor SwiftDua LipaTaylor SwiftRod WavePolo GS1mbaHeadie One, DrakeDua LipaRauw Alejandro, Chencho CorleoneJason Derulo, Puri, JhorrmountainAya NakamuratwocolorsTaylor SwiftKygo, Whitney HoustonJuanfranNLE ChoppaPost MaloneTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftDaBabyTaylor SwiftDoja Cat6ix9ineApache 207VIZE, Tom GregoryMegan Thee StallionTaylor SwiftTaylor SwiftTaylor SwiftA$AP FergApache 207Bonez MCFuture, Lil Uzi VertTaylor SwiftJuice WRLDNLE ChoppaJ BalvinEl Alfa, Chael ProduciendoRauw AlejandroTy Dolla $ignJ BalvinBillie EilishJ. ColeCapital Bra, Clueso, KC RebellThe Kid LAROIJuice WRLDOne DirectionUfo361, Sonus030Juice WRLDJuice WRLDJuice WRLDDripReportLil BabyOne DirectionLogicStaySolidRocky, Lil Uzi VertJuice WRLDJuice WRLDJuice WRLDJuice WRLDJuice WRLDTrevor DanielJuice WRLDLil TeccaMyke TowersLucianoBad Bunny6ix9ineLil Nas X, Billy Ray CyrusKid CudiAnuel AA, Daddy Yankee, KAROL G, Ozuna, J BalvinDalex, Lenny Tavárez, Chencho Corleone, Juhn, Dímelo FlowBad Bunny, SechJustin BieberRoddy RicchDoja CatPost MaloneDaBabyDímelo Flow, Arcangel, SechJuice WRLDJuice WRLDJuice WRLDKontra KKanye West, Travis ScottPop SmokeRed Velvet - IRENE & SEULGI6ix9ineAnuel AASam FischerPop SmokeY2K, bbno$Pop SmokePop SmokePop SmokePop SmokePop SmokePop SmokePop SmokePop SmokePop SmokeSleepy Hallow, FousheéTyla YawehPop SmokeBad Bunnyiann diorJhay Cortez, J Balvin, Bad BunnyAnuel AAImagine DragonsRauw Alejandro, Chencho Corleone, KEVVO, Bryant Myers, Lyanno, DalexPost MaloneJourneyBeyoncéMiksu / Macloud, Summer Cem, Luciano, JamuleAva MaxKaty PerryLil BabyLil Uzi VertTWICEMegan Thee StallionBring Me The HorizonJonas BrothersLauvPanic! At The DiscoDrakeDoja CatBoomdabash, Alessandra AmorosoKhalid, DisclosureDon ToliverPashanimBLACKPINKHarry StylesSelena GomezMaroon 5Bad Bunny, Don OmarTygaBonez MCCapital Bra, BozzaAnuel AAA Boogie Wit da HoodieJ. ColeBoshAlida, Robin SchulzLady GagaNLE ChoppaAlexander 23MEDUZA, GoodboysNiackBad Bunny, Daddy YankeePUBLICDaBabyPop Smoke, Rowdy RebelShabloUfo361, CÉLINELil Uzi VertMadison BeerNatalie TaylorNAVBad BunnyBad BunnyKygo, Zara Larsson, TygaCamila CabelloAlec BenjaminPARTYNEXTDOOR, RihannaApache 207XXXTENTACIONKC Rebell, Summer CemSam SmithChildish GambinoRauw Alejandro, FarrukoBad Bunny, Nicky JamShawn MendesJonas BrothersBad Bunny, TainyFutureLil Uzi VertXXXTENTACIONYNW MellyTwenty One PilotsLady GagaLady GagaLady GagaLady GagaLady GagaLady GagaLady GagaLady GagaLady GagaLady GagaLady GagaKygo, Kim PetrasKC Rebell, Summer CemKALIM, Ufo361Lil YachtyLil YachtyBonez MCKygo, Zak AbelApache 207Agust DGunnaThe WeekndGunnaCapital BraGunnaPost MaloneYandel, Bad BunnyJonas BrothersBad Bunny, Zion & LennoxSiaIUHalsey24kGoldnVicetone, Tony IgyThe WeekndTravis ScottTones And IArcangel, Sech, Romeo SantosjxdnSech, Daddy YankeeNicky Jam, Daddy YankeeFutureDrakeFuturePolo G, Stunna 4 Vegas, NLE Choppa, Mike WiLL Made-ItGusttavo LimaMigosPolo GBad BunnyG Herbo, Juice WRLD, Lil Uzi Vert, Chance the RapperTrippie Redd, PARTYNEXTDOORKina, Adriana ProenzaBad BunnyBad BunnyLil TjayBad Bunny, GabrielaBanda MS de Sergio Lizárraga, Snoop DoggCapital Bra, LoredanaBad BunnyDrakeAsheKehlaniTravis Scottbenny blancoYNW MellySam SmithBillie EilishFuture, Drake, Young ThugDrakeDrakeDrakeDrakeDrakeDrakeDrakeDrakeDrakeNAV, GunnaSelena GomezAli GatieUfo361DaBabyAnuel AADrakeCamilo, Evaluna MontanerPlayboi CartiTory LanezRauw Alejandro, Anuel AA, Natti Natasha, Farruko, LunayBROCKHAMPTONShirin DavidTravis ScottKSILil Uzi VertShakira, Anuel AAThe 1975Alan Walker, Ava MaxCamilo, Pedro CapóEllie GouldingG-EazyJ BalvinDaBabyDaBabyDaBabyLil Uzi VertRvssian, Anuel AA, Juice WRLDKygo, Sasha Alex SloanLil YachtyDaBabyKAROL G, Anuel AADominic FikeTory LanezTory LanezBonez MCSamraSam SmithITZYThe Chainsmokers, ILLENIUM, Lennon StellaRod WaveLunay, Myke Towers, Ozuna, Chencho Corleone, Rauw AlejandroPolo G, Stunna 4 VegasSub UrbanLizzoJustin BieberDemi Lovato5 Seconds of SummerBad BunnyThe WeekndLuísa SonzaLil BabyDua LipaBazziDua LipaDua LipaDua LipaThe WeekndThe WeekndDua LipaShiva, Eiffel 65Zuna, Loredana, SRNOThe Weeknd5 Seconds of SummerThe WeekndThe WeekndThe WeekndUfo361Bad Bunny, YaviahJhay Cortez, Anuel AA, J BalvinLittle Mix5 Seconds of SummerThe WeekndThe WeekndJ BalvinJ BalvinJ BalvinJ Balvin, Sky RompiendoLil Uzi VertLil Uzi VertNiall HoranLil Uzi VertJ Balvin, Mr EaziDaBabySelena GomezDardan, Monet192Bad BunnyChristian NodalJhené AikoBad BunnyBad Bunny, Anuel AALil Uzi VertLil Uzi Vert, 21 SavageDon ToliverLil Uzi VertBad Bunny, Duki, Pablo Chill-ELil Uzi VertNinhoBad Bunny, Ñengo FlowLil Uzi VertLil Uzi VertBad BunnyLil Uzi VertBad Bunny, MoraLil Uzi VertNiall HoranSZA, Justin TimberlakeNicky Jam, Anuel AATygaLil Uzi VertLauvLil Uzi VertLil Uzi VertLil Uzi VertLil Uzi VertLil Uzi VertBTSTones And ITainyBad BunnyUfo361Henrique & JulianoLil Uzi VertLil Uzi VertLil Uzi VertLil Uzi VertLil Uzi VertLil Uzi VertLil Uzi VertResidenteLil Uzi VertLil Uzi VertBTSBad Bunny, Kendo Kaponi, ArcangelLauvLil BabyGunnaBazziLauv, Troye SivanA Boogie Wit da HoodieMyke TowersBad Bunny, Myke TowersDaddy Yankee, SechEd SheeranPost MaloneLauvLunay, Ozuna, Anuel AASelena GomezDaBabyLauv, LANYLil Uzi VertLil BabyLil BabyLil BabyBTSApache 207Dalex, Lenny Tavárez, Anitta, Natti Natasha, Farruko, Justin QuilesArcangel, Bad BunnyDaddy YankeeLil Uzi VertTOKYO’S REVENGEStormzyFutureBTSCapital Bra, SamraMartin GarrixblackbearJ Balvin, Bad BunnyTaylor SwiftRich Music LTD, Sech, Dalex, Justin Quiles, Lenny Tavárez, Feid, Wisin, ZionLunay, Daddy Yankee, Bad BunnySHAEDLizzoBillie EilishBTSBTSBTSBTSBTSBTSBTSBTSBTSBTSThiaguinho MT, Mila, JS o Mão de OuroRich Music LTD, Sech, Dalex, Justin Quiles, Lenny Tavárez, FeidEminemBillie EilishPEDRO SAMPAIO, Felipe Original, JS o Mão de OuroK CAMPSech, OzunaMajor Lazer, DiploUfo361Reik, J Balvin, Lalo EbrattBillie EilishDalex, SechMigos, Travis Scott, Young ThugJustin BieberJustin BieberJustin BieberJustin BieberJustin BieberJustin BieberJustin BieberTame ImpalaJustin BieberJustin BieberLucianoJustin BieberTame ImpalaJustin Bieber5 Seconds of SummerA Boogie Wit da HoodieJustin BieberKygo, Sandro CavazzaJoker Bra, VIZETame ImpalaMac MillerBillie EilishTaylor SwiftTame ImpalaJustin BieberBillie EilishSam SmithJustin Bieber, QuavoNicki MinajAnt SaundersAnne-MarieTravis ScottLizzoLil WayneJustin Bieber, KehlaniROSALÍA, OzunaJustin Quiles, Natti Natasha, FarrukoTyler, The CreatorPiso 21, Christian NodalDJ Snake, J BalvinRed VelvetDaBabyROSALÍA, J Balvin, El GuinchoJonas BrothersKhalidKhalidTravis Scott, Young ThugSamraDaddy Yankee, SnowJ. ColeSech, Ozuna, Anuel AA, Darell, Nicky JamArizona ZervasA Boogie Wit da HoodieEminemSamraMatthew WilderJuju, Loredana, Miksu / MacloudHalseyKSIRiton, Oliver HeldensShakiraCamila CabelloMeek MillTaylor SwiftLil Nas XBillie EilishJ. Cole, Young ThugYNW MellyEminemEminemMac MillerHenrique & JulianoEminemGzuzEminemSamra, ELIFMegan Thee StallionSelena GomezMurda, EzhelJuice WRLDMalumaSam FeldtEminemEminemMac MillerMac MillerEminemMac MillerEminemEminemEminemEminemEminemMac MillerEminemMac MillerEminemEminemEminemHalseyMac MillerMac MillerMac MillerUfo361, FutureMac MillerGambiMaes, BoobaSelena GomezSelena GomezSelena GomezSelena GomezSelena GomezKhalidNiall HoranIdina Menzel, AURORASelena GomezSelena GomezLil MoseyPost MaloneRoddy RicchRoddy RicchMegan Thee StallionMabelTrippie Redd, DaBabyPedro Capó, FarrukoSelena GomezSelena GomezAnne-MarieDJ SnakeThe Chainsmokers, KygoJACKBOYS, Sheck WesDon ToliverJACKBOYS, Travis ScottFrench Montana24kGoldnApache 207Katy PerryCalvin HarrisOzunaSHAED, ZAYNJACKBOYS, Pop Smoke, Travis ScottDoja CatJACKBOYSAnitta, Lexa, Luísa SonzaLil Nas XJuice WRLDGradur, Heuss L'enfoiréDua LipaJorge & MateusCamila CabelloDadá Boladão, Tati Zaqui, OIKTaylor Swift to numeric", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m~/miniconda3/envs/math10s22/lib/python3.7/site-packages/pandas/core/nanops.py\u001b[0m in \u001b[0;36m_ensure_numeric\u001b[0;34m(x)\u001b[0m\n\u001b[1;32m 1602\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1603\u001b[0;31m \u001b[0mx\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfloat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1604\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mTypeError\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mValueError\u001b[0m: could not convert string to float: \"MåneskinThe Kid LAROIOlivia RodrigoEd SheeranLil Nas XLil Nas XDoja CatRauw AlejandroBad BunnyMåneskinDua LipaJ Balvin, Maria BecerraBTSJustin BieberBTSOlivia RodrigoOlivia RodrigoThe WeekndNio Garcia, J Balvin, Bad BunnyDoja CatMora, Bad Bunny, SechDoja CatOlivia RodrigoGlass AnimalsThe WeekndOlivia RodrigoFarrukoPost MaloneRiton, NightcrawlersMasked WolfBruno Mars, Anderson .Paak, Silk SonicCamila CabelloOlivia RodrigoSebastian Yatra, Myke TowersHarry StylesPolo GDoja Cat, The WeekndSech, Jhay CortezBad Bunny, Jhay CortezTINI, Maria BecerraOlivia RodrigoJ Balvin, KAROL G, Nicky Jam, Crissin, Totoy El Frio, Natan & ShanderBTSTiëstoGalantis24kGoldnTiago PZK, LIT killahWisin, Jhay Cortez, Anuel AA, Los Legendarios, Myke TowersBella PoarchBizarrap, Nicky JamMarc Seguí, Rauw Alejandro, Pol GranchBillie EilishMajestic, Boney M.MarshmelloSurf CurseJoão GomesRauw Alejandro, Mr. NaisgaiMaroon 5OneRepublicMegan Thee StallionATB, Topic, A7SOlivia RodrigoThe WeekndGiveonDua LipaTrinidad CardonaThe NeighbourhoodMalumaLewis CapaldiSmileySleepy HallowKAROL G, Mariah AngeliqJustin Quiles, Chimbala, Zion & LennoxShouseMåneskinKali UchisGera MX, Christian NodalLos Legendarios, Wisin, Jhay CortezTones And IThe Kid LAROIDrakeBo BurnhamDua LipaTravis Scott, HVMEJoel CorryJoel Corry, RAYE, David GuettaJustin Wellington, Small JamBelly, The Weeknd, Young ThugDuncan LaurenceMora, Jhay CortezAriana GrandePost MaloneRAF Camora, Bonez MCNatti Natasha, Becky GJ Balvin, SkrillexDoja CatWILLOWDaveLewis CapaldiDua LipaMadison BeerBANDIDOImagine DragonsInternet MoneyBruno MarsSAINt JHNSechBecky G, El AlfaIngrataxBillie EilishPost Malone, Swae LeedhruvDoja CatCalvin HarrisLuan SantanaEd SheeranShawn Mendes, Camila CabelloJustin BieberEd SheeranMYA, TINI, DukiBad Bunny, ROSALÍADaBabyConan GrayTate McRaeAviciiVance JoyNirvanaOlivia RodrigoThe NeighbourhoodJoão GomesTrippie ReddMaroon 5Tom OdellJamie MillerHozierTom GrennanGusttavo LimaCardi BMalumaKhalidQueenMyke Towers, JuhnMEDUZATravis ScottOfenbachCamilo, Shawn MendesLady Gaga, Bradley CooperCochise, $NOTMari FernandezOneRepublicColdplayEmilia, DukiJoão Gomes, Vitor FernandesAviciiMatheus Fernandes, DilsinhoVegedreamPop SmokeAURORADaBabyDaBabyJuice WRLDLil Tjay, 6LACKBillie EilishP!nk, Willow Sage HartPop SmokeOlivia RodrigoCardi BThe KillersThe PoliceFleetwood MacJames ArthurNormaniPop SmokePop SmokePowfu, beabadoobeeAnne-Marie, Niall HoranQueenDrake, WizKid, KylaHarry StylesSarah CothranWalker HayesRauw AlejandroJohn LegendPolo GPop SmokeSaweetieThe WeekndSZAAnne-Marie, Little MixBad BunnyAriana GrandeBlxst, TygaMC Zaquin, MC RickTopic, A7SLuísa SonzaRoddy RicchDaveEminemPop SmokePop SmokeTrippie Redd, Lil Uzi VertPop SmokePop SmokeKSIPop SmokePop SmokeTyler, The CreatorPashanimTion Wayne, Russ MillionsPop SmokeNio Garcia, Flow La MovieBLANCO, Sfera EbbastaRegardBillie EilishJohn MayerImagine DragonsMc Davi, Mc Pedrinho, Mc Don JuanInternet MoneyImagine DragonsDua LipaBTSSechSelena GomezBasOlivia RodrigoIsrael & Rodolffo, Wesley SafadãoTWICEBIAKane Brown, blackbearAlex Rose, Rauw AlejandroDj Guuga, DJ IvisMaluma, Beéle, Rauw Alejandro, Mambo Kingz, DJ Luian, DarellRauw AlejandroThe Chainsmokers, HalseyOasisBrent FaiyazDoja CatBig Red MachineTyler, The CreatorBo BurnhamDJ KhaledStarBoi3LordeBillie EilishShirin DavidCJIsrael & RodolffoMiley CyrusGym Class HeroesRauw Alejandro, Anuel AAsangiovanniBizarrap, Eladio CarrionArctic MonkeysTyler, The CreatorTyler, The CreatorTyler, The CreatorTyler, The CreatorTyler, The CreatorTyler, The CreatorTyler, The CreatorTyler, The CreatorTyler, The CreatorDoja CatTyler, The CreatorTyler, The CreatorDoja CatMigosDoja CatDoja CatFedez, Achille LauroJ Balvin, Dua Lipa, Bad BunnyJawsh 685, Jason DeruloCrissin, Totoy El Frio, Natan & ShanderBozaTate McRae, KhalidSoso ManessJ. ColeJ. ColeXXXTENTACIONPolo GRoddy RicchNathan EvansMacklemore & Ryan LewisJustin BieberMachine Gun KellyBruno MarsTravis ScottDua LipaDrakeMartin GarrixRochy RD, Myke Towers, Nicki NicoleLinkin ParkJ. ColeTravis ScottThe Chainsmokers, ColdplayRegard, Troye Sivan, Tate McRaeMigosPolo GPolo GMaroon 5MigosAva MaxMigosBlack Eyed Peas, ShakiraPolo GMigosBillie EilishBad BunnyMC Kevin o ChrisColdplayLil Nas XPolo GLady GagaLil Baby, Lil DurkJohn MayerLil Baby, Lil DurkTOMORROW X TOGETHER, SeoriJ. ColeLil TeccaYoung Stoner Life, Young Thug, GunnaManuel Turizo, Rauw Alejandro, Myke TowersHarry StylesMåneskinKAROL GAshnikkoEminemAlok, Mc Don Juan, Dj GBRJuice WRLDJuice WRLDBTSMalu, DJ Lucas BeatEminemLil MoseyGotye, KimbraJustin BieberMc Poze do Rodo, Neo Beats, MainstreetJ. ColeBTSBTSBarbara PraviTwenty One PilotsTwenty One PilotsJ. ColeNicki MinajBlind ChannelGo_AITZYJ. ColeDrakeJoyner Lucas, Lil BabyBeach BunnyGjon's TearsLil TjayDreamDaði FreyrTwenty One PilotsJ. ColeJ. ColeJ. ColeJ. ColeJ. ColeJ. ColeThe Kid LAROIBizarrap, Snow Tha ProductNio Garcia, Casper Magico, Ozuna, Wisin & Yandel, Myke Towers, Flow La MovieMARINAHarry StylesMyke TowersMilly, Farruko, Nio Garcia, Jay Wheeler, AmenazzyDaddy YankeeJustin BieberGym Class HeroesJP SaxeDJ KhaledRuss Millions, Tion WayneBillie EilishDon ToliverBizarrap, L-GanteLil Nas XPink Sweat$Future187 Strassenbande, Bonez MC, FrauenarztJuice WRLDNicky Jam, Romeo SantosRaí Saia RodadaCamilo, Evaluna MontanerJuice WRLDJuice WRLDJorge & MateusElyOttoBaby KeemMachine Gun KellyDJ KhaledDJ KhaledAnittaROSÉTaylor SwiftBillie EilishJ Balvin, KhalidDemi LovatoPooh ShiestyLil TjayWisin, Myke Towers, Los LegendariosJustin BieberH.E.R.HVMERitt MomneyDiego & Victor Hugo, Bruno & MarroneJames ArthurShawn MendesThe WeekndXXXTENTACIONMimi WebbblackbearBruno MarsKAROL G, Anuel AA, J BalvinTwenty One PilotsYoung Stoner Life, Young Thug, GunnaYoung Stoner Life, Young Thug, GunnaTaylor SwiftWesley Safadão, Os Barões Da PisadinhaOs Barões Da PisadinhaTaylor SwiftArctic MonkeysEd SheeranJ Balvin, Bad BunnyTaylor SwiftTaylor SwiftDMXTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftDMXTaylor SwiftTaylor SwiftTaylor SwiftSebastian Yatra, GuaynaaSech, Daddy Yankee, J Balvin, ROSALÍA, FarrukoTaylor SwiftTaylor SwiftKHEA, DukiDemi LovatoROSÉSam Fischer, Demi LovatoPop SmokeKevin Roldan, Bryant Myers, LyannoJason DeruloJustin BieberAriana GrandeMother MotherDJ IvisRusherking, KHEA, Duki, Maria Becerra, LIT killah, Tiago PZKMaroon 5, Wiz KhalifaJustin BieberJustin BieberJack Harlowa-haCamilo, El AlfaJ BalvinJustin BieberJustin BieberKAROL G, Nicki MinajOzuna, J Balvin, Chencho CorleoneJustin BieberZoe WeesDrakeDJ Ivis, Tarcísio do AcordeonJason Derulo, NukaJustin BieberThe Weeknd, Daft PunkFarrukoHugo & GuilhermeJustin BieberJustin BieberLana Del ReyNicky Jam, Myke TowersLana Del ReyMaluma, Lenny TavárezCamiloCamiloHippie SabotageJustin QuilesSelena GomezKSIDJ SnakeSiaMachine Gun KellyJay Wheeler, DJ Nelson, Myke TowersRobin SchulzDoja CatXXXTENTACIONTame ImpalaThe Weeknd, Daft PunkPop SmokeBANNERSPamungkasBLACKPINKNF, HopsinMadamePop SmokeJuice WRLDFrancesca Michielin, FedezAnuel AA, OzunaBooba, JSXLil BabyLele PonsOfenbach, QuarterheadLil PeepBØRNSConan GrayPost MaloneAriana GrandeC. Tangana, Niño de Elche, La HúngaraThe Kid LAROIJustin QuilesArizona ZervasPost MaloneC. Tangana, Ed MaverickHalseyBad BunnyJustin BieberClairoEd SheeranBausa, Apache 207NFShawn MendesSabrina CarpenterJack HarlowSara KaysJason Derulo, Maroon 5Tones And IOzuna, CamiloAriana GrandeEd SheeranKAROL GBizarrap, Nathy PelusoMaluma, The WeekndRauw AlejandroTarcísio do AcordeonXXXTENTACIONEd SheeranDrakeThe WeekndSurf MesaOasisXXXTENTACIONJuice WRLDBillie EilishSia, David GuettaThe Weekndbenny blancoThe WeekndMiley CyrusMartin GarrixBring Me The HorizonMalumaKawe, Mc Lele JPThe WeekndAriana GrandeDean LewisMegan Thee StallionJerry DiKASIMIR1441, badmómzjay, WILDBWOYSBrent Faiyaz, DJ DahiZAYNOlivia RodrigoAshnikkoMorgan WallenNio Garcia, Anuel AA, Myke Towers, Brray, JuankaAnuel AA, OzunaMigrantes, AlicoMorgan WallenSelena GomezJack HarlowSam Smith347aidanRauw Alejandro, J BalvinTaylor SwiftChris Brown, Young ThugJuice WRLD, The Kid LAROIAnne-Marie, KSI, Digital Farm AnimalsLuísa Sonza, Pabllo Vittar, AnittaErica BanksAva MaxBLACKPINKOzunaFousheéMorgan WallenMorgan WallenMorgan WallenBad BunnySech, J BalvinPop SmokeMorgan WallenMorgan WallenOs Barões Da PisadinhaBLACKPINKMarshmelloDua Lipa, AngèleApache 207Taylor SwiftSurfacesPetter Ferraz, Menor NicoMarshmello, BastilleQueenJ BalvinOs Barões Da Pisadinha, Xand AviãoKid CudiMEDUZA, Becky Hill, GoodboysTWICECORPSE, Savage Ga$pMariah CareyWham!Ariana GrandeBrenda LeeBobby HelmsMichael BubléAndy WilliamsKelly ClarksonJosé FelicianoDean MartinFrank SinatraJustin BieberThe RonettesBand AidPaul McCartneyMichael BubléJohn Lennon, Yoko OnoNat King ColeBing Crosby, Ken Darby Singers, John Scott Trotter & His OrchestraPlayboi CartiBurl IvesThe PoguesShakin' StevensElvis PresleyChuck BerryThe Jackson 5Kylie MinoguePerry Como, The Fontane SistersDarlene LoveElton JohnKid CudiJonas EsticadoJorge & MateusDaryl Hall & John OatesColdplaySam SmithSiaBritney SpearsBrett EldredgeJonas BrothersAva MaxGwen StefaniEminemNat King ColeMichael BubléIdina MenzelTaylor SwiftThe Jackson 5Eartha Kitt, Henri Rene & His OrchestraMykola Dmytrovych Leontovych, John WilliamsTaylor SwiftStevie WonderShawn MendesDean MartinBruce SpringsteenLeona LewisThe Beach BoysLiam PayneMeghan TrainorDean MartinFrank SinatraFrank SinatraMariah CareyBing CrosbyPentatonixDonny HathawayTony BennettTaylor SwiftKaty Perry*NSYNCTaylor SwiftEaglesMeghan TrainorTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftKid CudiKid CudiKid CudiKid CudiKid CudiKid CudiKid CudiBad BunnyKid CudiKid CudiTaylor SwiftJuice WRLDShawn MendesThe WeekndTory Lanez, Jack HarlowBad BunnyLil BabyMiley CyrusBTSsalem ileseBad Bunny, Jowell & Randy, Ñengo FlowBad BunnyThe Kid LAROIStudio Killers24kGoldnBad BunnyBad BunnyBad BunnyBad BunnyBad Bunny, ABRABad BunnyBad BunnyPaul McCartneyBTSBTSBTSBTSMiley CyrusTrio VegabajeñoMiley CyrusJhay Cortez, Bad BunnyBTSSfera EbbastaClean Bandit, MabelChristian Nodal, Ángela AguilarSfera EbbastaMaster KGSfera EbbastaAya NakamuraThe Kid LAROIJuice WRLDBLACKPINKJawsh 685, Jason DeruloJustin TimberlakeSfera Ebbasta21 Savage, Metro BoominWallowsDan + ShayVedoManuel TurizoStaySolidRockyFuture, Lil Uzi VertKane BrownK/DA, Madison Beer, (G)I-DLE, Lexie Liu, Jaira Burns, Seraphine, League of LegendsRauw AlejandroFuture, Lil Uzi VertOctavian, SkeptaAriana GrandeTy Dolla $ignLittle MixMAXFuture, Lil Uzi VertNelly Furtado, TimbalandDJ KhaledAriana GrandeLabrinthAnuel AA, Bad BunnyKinaDDGLuke CombsJojiDaddy Yankee, Anuel AA, Kendo KaponiBillie EilishCali Y El Dandee, Danna PaolaAriana GrandeAriana GrandeAriana GrandeThe Kid LAROIKHEAMalumaOzuna, KAROL G, Myke Towers21 Savage, Metro BoominPop SmokeAriana GrandeAriana GrandeEd SheeranCamiloDon ToliverJ BalvinAriana GrandeAriana GrandeAriana GrandeMichael JacksonSam SmithBonez MCSam SmithAC/DCAnittaMoney ManSechTravis ScottBLACKPINKBig SeanAriana GrandeBlack Eyed Peas, Ozuna, J. Rey SoulLauv, Conan GrayMarshmello, Demi LovatoTHE SCOTTS, Travis Scott, Kid CudiTrueno, Bizarrap, Taiu, TATOOLPassengerMelanie MartinezKygo, OneRepublicAdeleAli GatieCurtis WatersBLACKPINKG-Eazy13 Organisé, SCH, Kofs, Jul, Naps, Soso Maness, Elams, Solda, HouariBLACKPINKBebe RexhaROSALÍACamiloBad BunnyLana Del ReyGunnaRauw Alejandro, Dalex, Lenny TavárezNoah CyrusLewis CapaldiBLACKPINKBENEE, Gus Dapperton21 Savage, Metro BoominZAYNMachine Gun KellyNiackFeid, J Balvin, Justin QuilesChris Brown21 Savage, Metro Boomin21 Savage, Metro Boomin21 Savage, Metro BoominBryson Tiller21 Savage, Metro Boomin21 Savage, Metro Boomin21 Savage, Metro BoominInternet MoneyJoji21 Savage, Metro BoominWhoHeem21 Savage, Metro Boomin21 Savage, Metro BoominJojiJojiJoji, DiploPolo GMachine Gun KellyJojiJojiJojiBea MillerSaweetieJojiJoji, BENEECalvin HarrisJuice WRLD, Polo GMachine Gun KellyHarry NachJack HarlowKendrick Lamar, Jay RockInternet Money, DiploEarth, Wind & FireRegard, RAYEPolo GDamso, HamzaDamsoTaylor SwiftJuice WRLDJuice WRLDLil TeccaDrake6ix9ineDua LipaKygo, Donna SummerAva MaxAva MaxOzuna, Doja Cat, SiaSZA, The Neptunes, Pharrell Williams, Ty Dolla $ignMaroon 5MatuêBonez MCAlex Rose, Rafa PabönLil BabyBonez MC, MaxwellMiley CyrusDoja CatHeadie OneNeaBeyoncé, Megan Thee StallionBig SeanSaweetieITZYTravis ScottMalumaRobin Schulz, WesK/DA, (G)I-DLE, Wolftyla, Bea Miller, League of LegendsMc Zaac, Anitta, TygaPeach Tree RascalsTaylor SwiftBlack Eyed Peas, J BalvinKitschKrieg, Jamule, SFRKygo, Tina TurnerKaty PerryConkarahCordaeJACKBOYS, Travis ScottJowell & Randy, J BalvinAnuel AALady GagaRod WaveJuice WRLDJustin Quiles, Daddy Yankee, El AlfaInternet Money, Gunna, Don Toliver, NAVCapital Bra, CroBTSSam SmithJuice WRLDFeid, Justin QuilesBausa, JujuTaylor SwiftblackbearMustardBTSJason Mraz5 Seconds of SummerTaylor SwiftDua LipaTaylor SwiftRod WavePolo GS1mbaHeadie One, DrakeDua LipaRauw Alejandro, Chencho CorleoneJason Derulo, Puri, JhorrmountainAya NakamuratwocolorsTaylor SwiftKygo, Whitney HoustonJuanfranNLE ChoppaPost MaloneTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftDaBabyTaylor SwiftDoja Cat6ix9ineApache 207VIZE, Tom GregoryMegan Thee StallionTaylor SwiftTaylor SwiftTaylor SwiftA$AP FergApache 207Bonez MCFuture, Lil Uzi VertTaylor SwiftJuice WRLDNLE ChoppaJ BalvinEl Alfa, Chael ProduciendoRauw AlejandroTy Dolla $ignJ BalvinBillie EilishJ. ColeCapital Bra, Clueso, KC RebellThe Kid LAROIJuice WRLDOne DirectionUfo361, Sonus030Juice WRLDJuice WRLDJuice WRLDDripReportLil BabyOne DirectionLogicStaySolidRocky, Lil Uzi VertJuice WRLDJuice WRLDJuice WRLDJuice WRLDJuice WRLDTrevor DanielJuice WRLDLil TeccaMyke TowersLucianoBad Bunny6ix9ineLil Nas X, Billy Ray CyrusKid CudiAnuel AA, Daddy Yankee, KAROL G, Ozuna, J BalvinDalex, Lenny Tavárez, Chencho Corleone, Juhn, Dímelo FlowBad Bunny, SechJustin BieberRoddy RicchDoja CatPost MaloneDaBabyDímelo Flow, Arcangel, SechJuice WRLDJuice WRLDJuice WRLDKontra KKanye West, Travis ScottPop SmokeRed Velvet - IRENE & SEULGI6ix9ineAnuel AASam FischerPop SmokeY2K, bbno$Pop SmokePop SmokePop SmokePop SmokePop SmokePop SmokePop SmokePop SmokePop SmokeSleepy Hallow, FousheéTyla YawehPop SmokeBad Bunnyiann diorJhay Cortez, J Balvin, Bad BunnyAnuel AAImagine DragonsRauw Alejandro, Chencho Corleone, KEVVO, Bryant Myers, Lyanno, DalexPost MaloneJourneyBeyoncéMiksu / Macloud, Summer Cem, Luciano, JamuleAva MaxKaty PerryLil BabyLil Uzi VertTWICEMegan Thee StallionBring Me The HorizonJonas BrothersLauvPanic! At The DiscoDrakeDoja CatBoomdabash, Alessandra AmorosoKhalid, DisclosureDon ToliverPashanimBLACKPINKHarry StylesSelena GomezMaroon 5Bad Bunny, Don OmarTygaBonez MCCapital Bra, BozzaAnuel AAA Boogie Wit da HoodieJ. ColeBoshAlida, Robin SchulzLady GagaNLE ChoppaAlexander 23MEDUZA, GoodboysNiackBad Bunny, Daddy YankeePUBLICDaBabyPop Smoke, Rowdy RebelShabloUfo361, CÉLINELil Uzi VertMadison BeerNatalie TaylorNAVBad BunnyBad BunnyKygo, Zara Larsson, TygaCamila CabelloAlec BenjaminPARTYNEXTDOOR, RihannaApache 207XXXTENTACIONKC Rebell, Summer CemSam SmithChildish GambinoRauw Alejandro, FarrukoBad Bunny, Nicky JamShawn MendesJonas BrothersBad Bunny, TainyFutureLil Uzi VertXXXTENTACIONYNW MellyTwenty One PilotsLady GagaLady GagaLady GagaLady GagaLady GagaLady GagaLady GagaLady GagaLady GagaLady GagaLady GagaKygo, Kim PetrasKC Rebell, Summer CemKALIM, Ufo361Lil YachtyLil YachtyBonez MCKygo, Zak AbelApache 207Agust DGunnaThe WeekndGunnaCapital BraGunnaPost MaloneYandel, Bad BunnyJonas BrothersBad Bunny, Zion & LennoxSiaIUHalsey24kGoldnVicetone, Tony IgyThe WeekndTravis ScottTones And IArcangel, Sech, Romeo SantosjxdnSech, Daddy YankeeNicky Jam, Daddy YankeeFutureDrakeFuturePolo G, Stunna 4 Vegas, NLE Choppa, Mike WiLL Made-ItGusttavo LimaMigosPolo GBad BunnyG Herbo, Juice WRLD, Lil Uzi Vert, Chance the RapperTrippie Redd, PARTYNEXTDOORKina, Adriana ProenzaBad BunnyBad BunnyLil TjayBad Bunny, GabrielaBanda MS de Sergio Lizárraga, Snoop DoggCapital Bra, LoredanaBad BunnyDrakeAsheKehlaniTravis Scottbenny blancoYNW MellySam SmithBillie EilishFuture, Drake, Young ThugDrakeDrakeDrakeDrakeDrakeDrakeDrakeDrakeDrakeNAV, GunnaSelena GomezAli GatieUfo361DaBabyAnuel AADrakeCamilo, Evaluna MontanerPlayboi CartiTory LanezRauw Alejandro, Anuel AA, Natti Natasha, Farruko, LunayBROCKHAMPTONShirin DavidTravis ScottKSILil Uzi VertShakira, Anuel AAThe 1975Alan Walker, Ava MaxCamilo, Pedro CapóEllie GouldingG-EazyJ BalvinDaBabyDaBabyDaBabyLil Uzi VertRvssian, Anuel AA, Juice WRLDKygo, Sasha Alex SloanLil YachtyDaBabyKAROL G, Anuel AADominic FikeTory LanezTory LanezBonez MCSamraSam SmithITZYThe Chainsmokers, ILLENIUM, Lennon StellaRod WaveLunay, Myke Towers, Ozuna, Chencho Corleone, Rauw AlejandroPolo G, Stunna 4 VegasSub UrbanLizzoJustin BieberDemi Lovato5 Seconds of SummerBad BunnyThe WeekndLuísa SonzaLil BabyDua LipaBazziDua LipaDua LipaDua LipaThe WeekndThe WeekndDua LipaShiva, Eiffel 65Zuna, Loredana, SRNOThe Weeknd5 Seconds of SummerThe WeekndThe WeekndThe WeekndUfo361Bad Bunny, YaviahJhay Cortez, Anuel AA, J BalvinLittle Mix5 Seconds of SummerThe WeekndThe WeekndJ BalvinJ BalvinJ BalvinJ Balvin, Sky RompiendoLil Uzi VertLil Uzi VertNiall HoranLil Uzi VertJ Balvin, Mr EaziDaBabySelena GomezDardan, Monet192Bad BunnyChristian NodalJhené AikoBad BunnyBad Bunny, Anuel AALil Uzi VertLil Uzi Vert, 21 SavageDon ToliverLil Uzi VertBad Bunny, Duki, Pablo Chill-ELil Uzi VertNinhoBad Bunny, Ñengo FlowLil Uzi VertLil Uzi VertBad BunnyLil Uzi VertBad Bunny, MoraLil Uzi VertNiall HoranSZA, Justin TimberlakeNicky Jam, Anuel AATygaLil Uzi VertLauvLil Uzi VertLil Uzi VertLil Uzi VertLil Uzi VertLil Uzi VertBTSTones And ITainyBad BunnyUfo361Henrique & JulianoLil Uzi VertLil Uzi VertLil Uzi VertLil Uzi VertLil Uzi VertLil Uzi VertLil Uzi VertResidenteLil Uzi VertLil Uzi VertBTSBad Bunny, Kendo Kaponi, ArcangelLauvLil BabyGunnaBazziLauv, Troye SivanA Boogie Wit da HoodieMyke TowersBad Bunny, Myke TowersDaddy Yankee, SechEd SheeranPost MaloneLauvLunay, Ozuna, Anuel AASelena GomezDaBabyLauv, LANYLil Uzi VertLil BabyLil BabyLil BabyBTSApache 207Dalex, Lenny Tavárez, Anitta, Natti Natasha, Farruko, Justin QuilesArcangel, Bad BunnyDaddy YankeeLil Uzi VertTOKYO’S REVENGEStormzyFutureBTSCapital Bra, SamraMartin GarrixblackbearJ Balvin, Bad BunnyTaylor SwiftRich Music LTD, Sech, Dalex, Justin Quiles, Lenny Tavárez, Feid, Wisin, ZionLunay, Daddy Yankee, Bad BunnySHAEDLizzoBillie EilishBTSBTSBTSBTSBTSBTSBTSBTSBTSBTSThiaguinho MT, Mila, JS o Mão de OuroRich Music LTD, Sech, Dalex, Justin Quiles, Lenny Tavárez, FeidEminemBillie EilishPEDRO SAMPAIO, Felipe Original, JS o Mão de OuroK CAMPSech, OzunaMajor Lazer, DiploUfo361Reik, J Balvin, Lalo EbrattBillie EilishDalex, SechMigos, Travis Scott, Young ThugJustin BieberJustin BieberJustin BieberJustin BieberJustin BieberJustin BieberJustin BieberTame ImpalaJustin BieberJustin BieberLucianoJustin BieberTame ImpalaJustin Bieber5 Seconds of SummerA Boogie Wit da HoodieJustin BieberKygo, Sandro CavazzaJoker Bra, VIZETame ImpalaMac MillerBillie EilishTaylor SwiftTame ImpalaJustin BieberBillie EilishSam SmithJustin Bieber, QuavoNicki MinajAnt SaundersAnne-MarieTravis ScottLizzoLil WayneJustin Bieber, KehlaniROSALÍA, OzunaJustin Quiles, Natti Natasha, FarrukoTyler, The CreatorPiso 21, Christian NodalDJ Snake, J BalvinRed VelvetDaBabyROSALÍA, J Balvin, El GuinchoJonas BrothersKhalidKhalidTravis Scott, Young ThugSamraDaddy Yankee, SnowJ. ColeSech, Ozuna, Anuel AA, Darell, Nicky JamArizona ZervasA Boogie Wit da HoodieEminemSamraMatthew WilderJuju, Loredana, Miksu / MacloudHalseyKSIRiton, Oliver HeldensShakiraCamila CabelloMeek MillTaylor SwiftLil Nas XBillie EilishJ. Cole, Young ThugYNW MellyEminemEminemMac MillerHenrique & JulianoEminemGzuzEminemSamra, ELIFMegan Thee StallionSelena GomezMurda, EzhelJuice WRLDMalumaSam FeldtEminemEminemMac MillerMac MillerEminemMac MillerEminemEminemEminemEminemEminemMac MillerEminemMac MillerEminemEminemEminemHalseyMac MillerMac MillerMac MillerUfo361, FutureMac MillerGambiMaes, BoobaSelena GomezSelena GomezSelena GomezSelena GomezSelena GomezKhalidNiall HoranIdina Menzel, AURORASelena GomezSelena GomezLil MoseyPost MaloneRoddy RicchRoddy RicchMegan Thee StallionMabelTrippie Redd, DaBabyPedro Capó, FarrukoSelena GomezSelena GomezAnne-MarieDJ SnakeThe Chainsmokers, KygoJACKBOYS, Sheck WesDon ToliverJACKBOYS, Travis ScottFrench Montana24kGoldnApache 207Katy PerryCalvin HarrisOzunaSHAED, ZAYNJACKBOYS, Pop Smoke, Travis ScottDoja CatJACKBOYSAnitta, Lexa, Luísa SonzaLil Nas XJuice WRLDGradur, Heuss L'enfoiréDua LipaJorge & MateusCamila CabelloDadá Boladão, Tati Zaqui, OIKTaylor Swift\"", "\nDuring handling of the above exception, another exception occurred:\n", "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m~/miniconda3/envs/math10s22/lib/python3.7/site-packages/pandas/core/nanops.py\u001b[0m in \u001b[0;36m_ensure_numeric\u001b[0;34m(x)\u001b[0m\n\u001b[1;32m 1606\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1607\u001b[0;31m \u001b[0mx\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcomplex\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1608\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mValueError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mValueError\u001b[0m: complex() arg is a malformed string", "\nThe above exception was the direct cause of the following exception:\n", "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m/var/folders/8j/gshrlmtn7dg4qtztj4d4t_w40000gn/T/ipykernel_60426/3328112774.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mdf2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;32mlambda\u001b[0m \u001b[0ms\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0ms\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0ms\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmean\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;32m~/miniconda3/envs/math10s22/lib/python3.7/site-packages/pandas/core/frame.py\u001b[0m in \u001b[0;36mapply\u001b[0;34m(self, func, axis, raw, result_type, args, **kwargs)\u001b[0m\n\u001b[1;32m 8738\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8739\u001b[0m )\n\u001b[0;32m-> 8740\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mop\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8741\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8742\u001b[0m def applymap(\n", "\u001b[0;32m~/miniconda3/envs/math10s22/lib/python3.7/site-packages/pandas/core/apply.py\u001b[0m in \u001b[0;36mapply\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 686\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply_raw\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 687\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 688\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply_standard\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 689\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 690\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0magg\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/miniconda3/envs/math10s22/lib/python3.7/site-packages/pandas/core/apply.py\u001b[0m in \u001b[0;36mapply_standard\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 810\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 811\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mapply_standard\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 812\u001b[0;31m \u001b[0mresults\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mres_index\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply_series_generator\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 813\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 814\u001b[0m \u001b[0;31m# wrap results\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/miniconda3/envs/math10s22/lib/python3.7/site-packages/pandas/core/apply.py\u001b[0m in \u001b[0;36mapply_series_generator\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 826\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mv\u001b[0m \u001b[0;32min\u001b[0m \u001b[0menumerate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mseries_gen\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 827\u001b[0m \u001b[0;31m# ignore SettingWithCopy here in case the user mutates\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 828\u001b[0;31m \u001b[0mresults\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mv\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 829\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mresults\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mABCSeries\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 830\u001b[0m \u001b[0;31m# If we have a view on v, we need to make a copy because\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/var/folders/8j/gshrlmtn7dg4qtztj4d4t_w40000gn/T/ipykernel_60426/3328112774.py\u001b[0m in \u001b[0;36m\u001b[0;34m(s)\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mdf2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;32mlambda\u001b[0m \u001b[0ms\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0ms\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0ms\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmean\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;32m~/miniconda3/envs/math10s22/lib/python3.7/site-packages/pandas/core/generic.py\u001b[0m in \u001b[0;36mmean\u001b[0;34m(self, axis, skipna, level, numeric_only, **kwargs)\u001b[0m\n\u001b[1;32m 10749\u001b[0m )\n\u001b[1;32m 10750\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mmean\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mskipna\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlevel\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnumeric_only\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m> 10751\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mNDFrame\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmean\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mskipna\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlevel\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnumeric_only\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 10752\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 10753\u001b[0m \u001b[0msetattr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcls\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"mean\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmean\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/miniconda3/envs/math10s22/lib/python3.7/site-packages/pandas/core/generic.py\u001b[0m in \u001b[0;36mmean\u001b[0;34m(self, axis, skipna, level, numeric_only, **kwargs)\u001b[0m\n\u001b[1;32m 10368\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mmean\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mskipna\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlevel\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnumeric_only\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 10369\u001b[0m return self._stat_function(\n\u001b[0;32m> 10370\u001b[0;31m \u001b[0;34m\"mean\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnanops\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mnanmean\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mskipna\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlevel\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnumeric_only\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 10371\u001b[0m )\n\u001b[1;32m 10372\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/miniconda3/envs/math10s22/lib/python3.7/site-packages/pandas/core/generic.py\u001b[0m in \u001b[0;36m_stat_function\u001b[0;34m(self, name, func, axis, skipna, level, numeric_only, **kwargs)\u001b[0m\n\u001b[1;32m 10353\u001b[0m )\n\u001b[1;32m 10354\u001b[0m return self._reduce(\n\u001b[0;32m> 10355\u001b[0;31m \u001b[0mfunc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0maxis\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mskipna\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mskipna\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnumeric_only\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mnumeric_only\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 10356\u001b[0m )\n\u001b[1;32m 10357\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/miniconda3/envs/math10s22/lib/python3.7/site-packages/pandas/core/series.py\u001b[0m in \u001b[0;36m_reduce\u001b[0;34m(self, op, name, axis, skipna, numeric_only, filter_type, **kwds)\u001b[0m\n\u001b[1;32m 4390\u001b[0m )\n\u001b[1;32m 4391\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0merrstate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mall\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"ignore\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 4392\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mop\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdelegate\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mskipna\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mskipna\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4393\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4394\u001b[0m def _reindex_indexer(\n", "\u001b[0;32m~/miniconda3/envs/math10s22/lib/python3.7/site-packages/pandas/core/nanops.py\u001b[0m in \u001b[0;36m_f\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 92\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 93\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0merrstate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minvalid\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"ignore\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 94\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 95\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mValueError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 96\u001b[0m \u001b[0;31m# we want to transform an object array\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/miniconda3/envs/math10s22/lib/python3.7/site-packages/pandas/core/nanops.py\u001b[0m in \u001b[0;36mf\u001b[0;34m(values, axis, skipna, **kwds)\u001b[0m\n\u001b[1;32m 154\u001b[0m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0malt\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0maxis\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mskipna\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mskipna\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 155\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 156\u001b[0;31m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0malt\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0maxis\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mskipna\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mskipna\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 157\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 158\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/miniconda3/envs/math10s22/lib/python3.7/site-packages/pandas/core/nanops.py\u001b[0m in \u001b[0;36mnew_func\u001b[0;34m(values, axis, skipna, mask, **kwargs)\u001b[0m\n\u001b[1;32m 409\u001b[0m \u001b[0mmask\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0misna\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 410\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 411\u001b[0;31m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0maxis\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mskipna\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mskipna\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmask\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmask\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 412\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 413\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mdatetimelike\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/miniconda3/envs/math10s22/lib/python3.7/site-packages/pandas/core/nanops.py\u001b[0m in \u001b[0;36mnanmean\u001b[0;34m(values, axis, skipna, mask)\u001b[0m\n\u001b[1;32m 664\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 665\u001b[0m \u001b[0mcount\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_get_counts\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmask\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdtype\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdtype_count\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 666\u001b[0;31m \u001b[0mthe_sum\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_ensure_numeric\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msum\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0maxis\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdtype\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdtype_sum\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 667\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 668\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0maxis\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mgetattr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mthe_sum\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"ndim\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;32mFalse\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/miniconda3/envs/math10s22/lib/python3.7/site-packages/pandas/core/nanops.py\u001b[0m in \u001b[0;36m_ensure_numeric\u001b[0;34m(x)\u001b[0m\n\u001b[1;32m 1608\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mValueError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1609\u001b[0m \u001b[0;31m# e.g. \"foo\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1610\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34mf\"Could not convert {x} to numeric\"\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0merr\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1611\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1612\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mTypeError\u001b[0m: Could not convert MåneskinThe Kid LAROIOlivia RodrigoEd SheeranLil Nas XLil Nas XDoja CatRauw AlejandroBad BunnyMåneskinDua LipaJ Balvin, Maria BecerraBTSJustin BieberBTSOlivia RodrigoOlivia RodrigoThe WeekndNio Garcia, J Balvin, Bad BunnyDoja CatMora, Bad Bunny, SechDoja CatOlivia RodrigoGlass AnimalsThe WeekndOlivia RodrigoFarrukoPost MaloneRiton, NightcrawlersMasked WolfBruno Mars, Anderson .Paak, Silk SonicCamila CabelloOlivia RodrigoSebastian Yatra, Myke TowersHarry StylesPolo GDoja Cat, The WeekndSech, Jhay CortezBad Bunny, Jhay CortezTINI, Maria BecerraOlivia RodrigoJ Balvin, KAROL G, Nicky Jam, Crissin, Totoy El Frio, Natan & ShanderBTSTiëstoGalantis24kGoldnTiago PZK, LIT killahWisin, Jhay Cortez, Anuel AA, Los Legendarios, Myke TowersBella PoarchBizarrap, Nicky JamMarc Seguí, Rauw Alejandro, Pol GranchBillie EilishMajestic, Boney M.MarshmelloSurf CurseJoão GomesRauw Alejandro, Mr. NaisgaiMaroon 5OneRepublicMegan Thee StallionATB, Topic, A7SOlivia RodrigoThe WeekndGiveonDua LipaTrinidad CardonaThe NeighbourhoodMalumaLewis CapaldiSmileySleepy HallowKAROL G, Mariah AngeliqJustin Quiles, Chimbala, Zion & LennoxShouseMåneskinKali UchisGera MX, Christian NodalLos Legendarios, Wisin, Jhay CortezTones And IThe Kid LAROIDrakeBo BurnhamDua LipaTravis Scott, HVMEJoel CorryJoel Corry, RAYE, David GuettaJustin Wellington, Small JamBelly, The Weeknd, Young ThugDuncan LaurenceMora, Jhay CortezAriana GrandePost MaloneRAF Camora, Bonez MCNatti Natasha, Becky GJ Balvin, SkrillexDoja CatWILLOWDaveLewis CapaldiDua LipaMadison BeerBANDIDOImagine DragonsInternet MoneyBruno MarsSAINt JHNSechBecky G, El AlfaIngrataxBillie EilishPost Malone, Swae LeedhruvDoja CatCalvin HarrisLuan SantanaEd SheeranShawn Mendes, Camila CabelloJustin BieberEd SheeranMYA, TINI, DukiBad Bunny, ROSALÍADaBabyConan GrayTate McRaeAviciiVance JoyNirvanaOlivia RodrigoThe NeighbourhoodJoão GomesTrippie ReddMaroon 5Tom OdellJamie MillerHozierTom GrennanGusttavo LimaCardi BMalumaKhalidQueenMyke Towers, JuhnMEDUZATravis ScottOfenbachCamilo, Shawn MendesLady Gaga, Bradley CooperCochise, $NOTMari FernandezOneRepublicColdplayEmilia, DukiJoão Gomes, Vitor FernandesAviciiMatheus Fernandes, DilsinhoVegedreamPop SmokeAURORADaBabyDaBabyJuice WRLDLil Tjay, 6LACKBillie EilishP!nk, Willow Sage HartPop SmokeOlivia RodrigoCardi BThe KillersThe PoliceFleetwood MacJames ArthurNormaniPop SmokePop SmokePowfu, beabadoobeeAnne-Marie, Niall HoranQueenDrake, WizKid, KylaHarry StylesSarah CothranWalker HayesRauw AlejandroJohn LegendPolo GPop SmokeSaweetieThe WeekndSZAAnne-Marie, Little MixBad BunnyAriana GrandeBlxst, TygaMC Zaquin, MC RickTopic, A7SLuísa SonzaRoddy RicchDaveEminemPop SmokePop SmokeTrippie Redd, Lil Uzi VertPop SmokePop SmokeKSIPop SmokePop SmokeTyler, The CreatorPashanimTion Wayne, Russ MillionsPop SmokeNio Garcia, Flow La MovieBLANCO, Sfera EbbastaRegardBillie EilishJohn MayerImagine DragonsMc Davi, Mc Pedrinho, Mc Don JuanInternet MoneyImagine DragonsDua LipaBTSSechSelena GomezBasOlivia RodrigoIsrael & Rodolffo, Wesley SafadãoTWICEBIAKane Brown, blackbearAlex Rose, Rauw AlejandroDj Guuga, DJ IvisMaluma, Beéle, Rauw Alejandro, Mambo Kingz, DJ Luian, DarellRauw AlejandroThe Chainsmokers, HalseyOasisBrent FaiyazDoja CatBig Red MachineTyler, The CreatorBo BurnhamDJ KhaledStarBoi3LordeBillie EilishShirin DavidCJIsrael & RodolffoMiley CyrusGym Class HeroesRauw Alejandro, Anuel AAsangiovanniBizarrap, Eladio CarrionArctic MonkeysTyler, The CreatorTyler, The CreatorTyler, The CreatorTyler, The CreatorTyler, The CreatorTyler, The CreatorTyler, The CreatorTyler, The CreatorTyler, The CreatorDoja CatTyler, The CreatorTyler, The CreatorDoja CatMigosDoja CatDoja CatFedez, Achille LauroJ Balvin, Dua Lipa, Bad BunnyJawsh 685, Jason DeruloCrissin, Totoy El Frio, Natan & ShanderBozaTate McRae, KhalidSoso ManessJ. ColeJ. ColeXXXTENTACIONPolo GRoddy RicchNathan EvansMacklemore & Ryan LewisJustin BieberMachine Gun KellyBruno MarsTravis ScottDua LipaDrakeMartin GarrixRochy RD, Myke Towers, Nicki NicoleLinkin ParkJ. ColeTravis ScottThe Chainsmokers, ColdplayRegard, Troye Sivan, Tate McRaeMigosPolo GPolo GMaroon 5MigosAva MaxMigosBlack Eyed Peas, ShakiraPolo GMigosBillie EilishBad BunnyMC Kevin o ChrisColdplayLil Nas XPolo GLady GagaLil Baby, Lil DurkJohn MayerLil Baby, Lil DurkTOMORROW X TOGETHER, SeoriJ. ColeLil TeccaYoung Stoner Life, Young Thug, GunnaManuel Turizo, Rauw Alejandro, Myke TowersHarry StylesMåneskinKAROL GAshnikkoEminemAlok, Mc Don Juan, Dj GBRJuice WRLDJuice WRLDBTSMalu, DJ Lucas BeatEminemLil MoseyGotye, KimbraJustin BieberMc Poze do Rodo, Neo Beats, MainstreetJ. ColeBTSBTSBarbara PraviTwenty One PilotsTwenty One PilotsJ. ColeNicki MinajBlind ChannelGo_AITZYJ. ColeDrakeJoyner Lucas, Lil BabyBeach BunnyGjon's TearsLil TjayDreamDaði FreyrTwenty One PilotsJ. ColeJ. ColeJ. ColeJ. ColeJ. ColeJ. ColeThe Kid LAROIBizarrap, Snow Tha ProductNio Garcia, Casper Magico, Ozuna, Wisin & Yandel, Myke Towers, Flow La MovieMARINAHarry StylesMyke TowersMilly, Farruko, Nio Garcia, Jay Wheeler, AmenazzyDaddy YankeeJustin BieberGym Class HeroesJP SaxeDJ KhaledRuss Millions, Tion WayneBillie EilishDon ToliverBizarrap, L-GanteLil Nas XPink Sweat$Future187 Strassenbande, Bonez MC, FrauenarztJuice WRLDNicky Jam, Romeo SantosRaí Saia RodadaCamilo, Evaluna MontanerJuice WRLDJuice WRLDJorge & MateusElyOttoBaby KeemMachine Gun KellyDJ KhaledDJ KhaledAnittaROSÉTaylor SwiftBillie EilishJ Balvin, KhalidDemi LovatoPooh ShiestyLil TjayWisin, Myke Towers, Los LegendariosJustin BieberH.E.R.HVMERitt MomneyDiego & Victor Hugo, Bruno & MarroneJames ArthurShawn MendesThe WeekndXXXTENTACIONMimi WebbblackbearBruno MarsKAROL G, Anuel AA, J BalvinTwenty One PilotsYoung Stoner Life, Young Thug, GunnaYoung Stoner Life, Young Thug, GunnaTaylor SwiftWesley Safadão, Os Barões Da PisadinhaOs Barões Da PisadinhaTaylor SwiftArctic MonkeysEd SheeranJ Balvin, Bad BunnyTaylor SwiftTaylor SwiftDMXTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftDMXTaylor SwiftTaylor SwiftTaylor SwiftSebastian Yatra, GuaynaaSech, Daddy Yankee, J Balvin, ROSALÍA, FarrukoTaylor SwiftTaylor SwiftKHEA, DukiDemi LovatoROSÉSam Fischer, Demi LovatoPop SmokeKevin Roldan, Bryant Myers, LyannoJason DeruloJustin BieberAriana GrandeMother MotherDJ IvisRusherking, KHEA, Duki, Maria Becerra, LIT killah, Tiago PZKMaroon 5, Wiz KhalifaJustin BieberJustin BieberJack Harlowa-haCamilo, El AlfaJ BalvinJustin BieberJustin BieberKAROL G, Nicki MinajOzuna, J Balvin, Chencho CorleoneJustin BieberZoe WeesDrakeDJ Ivis, Tarcísio do AcordeonJason Derulo, NukaJustin BieberThe Weeknd, Daft PunkFarrukoHugo & GuilhermeJustin BieberJustin BieberLana Del ReyNicky Jam, Myke TowersLana Del ReyMaluma, Lenny TavárezCamiloCamiloHippie SabotageJustin QuilesSelena GomezKSIDJ SnakeSiaMachine Gun KellyJay Wheeler, DJ Nelson, Myke TowersRobin SchulzDoja CatXXXTENTACIONTame ImpalaThe Weeknd, Daft PunkPop SmokeBANNERSPamungkasBLACKPINKNF, HopsinMadamePop SmokeJuice WRLDFrancesca Michielin, FedezAnuel AA, OzunaBooba, JSXLil BabyLele PonsOfenbach, QuarterheadLil PeepBØRNSConan GrayPost MaloneAriana GrandeC. Tangana, Niño de Elche, La HúngaraThe Kid LAROIJustin QuilesArizona ZervasPost MaloneC. Tangana, Ed MaverickHalseyBad BunnyJustin BieberClairoEd SheeranBausa, Apache 207NFShawn MendesSabrina CarpenterJack HarlowSara KaysJason Derulo, Maroon 5Tones And IOzuna, CamiloAriana GrandeEd SheeranKAROL GBizarrap, Nathy PelusoMaluma, The WeekndRauw AlejandroTarcísio do AcordeonXXXTENTACIONEd SheeranDrakeThe WeekndSurf MesaOasisXXXTENTACIONJuice WRLDBillie EilishSia, David GuettaThe Weekndbenny blancoThe WeekndMiley CyrusMartin GarrixBring Me The HorizonMalumaKawe, Mc Lele JPThe WeekndAriana GrandeDean LewisMegan Thee StallionJerry DiKASIMIR1441, badmómzjay, WILDBWOYSBrent Faiyaz, DJ DahiZAYNOlivia RodrigoAshnikkoMorgan WallenNio Garcia, Anuel AA, Myke Towers, Brray, JuankaAnuel AA, OzunaMigrantes, AlicoMorgan WallenSelena GomezJack HarlowSam Smith347aidanRauw Alejandro, J BalvinTaylor SwiftChris Brown, Young ThugJuice WRLD, The Kid LAROIAnne-Marie, KSI, Digital Farm AnimalsLuísa Sonza, Pabllo Vittar, AnittaErica BanksAva MaxBLACKPINKOzunaFousheéMorgan WallenMorgan WallenMorgan WallenBad BunnySech, J BalvinPop SmokeMorgan WallenMorgan WallenOs Barões Da PisadinhaBLACKPINKMarshmelloDua Lipa, AngèleApache 207Taylor SwiftSurfacesPetter Ferraz, Menor NicoMarshmello, BastilleQueenJ BalvinOs Barões Da Pisadinha, Xand AviãoKid CudiMEDUZA, Becky Hill, GoodboysTWICECORPSE, Savage Ga$pMariah CareyWham!Ariana GrandeBrenda LeeBobby HelmsMichael BubléAndy WilliamsKelly ClarksonJosé FelicianoDean MartinFrank SinatraJustin BieberThe RonettesBand AidPaul McCartneyMichael BubléJohn Lennon, Yoko OnoNat King ColeBing Crosby, Ken Darby Singers, John Scott Trotter & His OrchestraPlayboi CartiBurl IvesThe PoguesShakin' StevensElvis PresleyChuck BerryThe Jackson 5Kylie MinoguePerry Como, The Fontane SistersDarlene LoveElton JohnKid CudiJonas EsticadoJorge & MateusDaryl Hall & John OatesColdplaySam SmithSiaBritney SpearsBrett EldredgeJonas BrothersAva MaxGwen StefaniEminemNat King ColeMichael BubléIdina MenzelTaylor SwiftThe Jackson 5Eartha Kitt, Henri Rene & His OrchestraMykola Dmytrovych Leontovych, John WilliamsTaylor SwiftStevie WonderShawn MendesDean MartinBruce SpringsteenLeona LewisThe Beach BoysLiam PayneMeghan TrainorDean MartinFrank SinatraFrank SinatraMariah CareyBing CrosbyPentatonixDonny HathawayTony BennettTaylor SwiftKaty Perry*NSYNCTaylor SwiftEaglesMeghan TrainorTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftKid CudiKid CudiKid CudiKid CudiKid CudiKid CudiKid CudiBad BunnyKid CudiKid CudiTaylor SwiftJuice WRLDShawn MendesThe WeekndTory Lanez, Jack HarlowBad BunnyLil BabyMiley CyrusBTSsalem ileseBad Bunny, Jowell & Randy, Ñengo FlowBad BunnyThe Kid LAROIStudio Killers24kGoldnBad BunnyBad BunnyBad BunnyBad BunnyBad Bunny, ABRABad BunnyBad BunnyPaul McCartneyBTSBTSBTSBTSMiley CyrusTrio VegabajeñoMiley CyrusJhay Cortez, Bad BunnyBTSSfera EbbastaClean Bandit, MabelChristian Nodal, Ángela AguilarSfera EbbastaMaster KGSfera EbbastaAya NakamuraThe Kid LAROIJuice WRLDBLACKPINKJawsh 685, Jason DeruloJustin TimberlakeSfera Ebbasta21 Savage, Metro BoominWallowsDan + ShayVedoManuel TurizoStaySolidRockyFuture, Lil Uzi VertKane BrownK/DA, Madison Beer, (G)I-DLE, Lexie Liu, Jaira Burns, Seraphine, League of LegendsRauw AlejandroFuture, Lil Uzi VertOctavian, SkeptaAriana GrandeTy Dolla $ignLittle MixMAXFuture, Lil Uzi VertNelly Furtado, TimbalandDJ KhaledAriana GrandeLabrinthAnuel AA, Bad BunnyKinaDDGLuke CombsJojiDaddy Yankee, Anuel AA, Kendo KaponiBillie EilishCali Y El Dandee, Danna PaolaAriana GrandeAriana GrandeAriana GrandeThe Kid LAROIKHEAMalumaOzuna, KAROL G, Myke Towers21 Savage, Metro BoominPop SmokeAriana GrandeAriana GrandeEd SheeranCamiloDon ToliverJ BalvinAriana GrandeAriana GrandeAriana GrandeMichael JacksonSam SmithBonez MCSam SmithAC/DCAnittaMoney ManSechTravis ScottBLACKPINKBig SeanAriana GrandeBlack Eyed Peas, Ozuna, J. Rey SoulLauv, Conan GrayMarshmello, Demi LovatoTHE SCOTTS, Travis Scott, Kid CudiTrueno, Bizarrap, Taiu, TATOOLPassengerMelanie MartinezKygo, OneRepublicAdeleAli GatieCurtis WatersBLACKPINKG-Eazy13 Organisé, SCH, Kofs, Jul, Naps, Soso Maness, Elams, Solda, HouariBLACKPINKBebe RexhaROSALÍACamiloBad BunnyLana Del ReyGunnaRauw Alejandro, Dalex, Lenny TavárezNoah CyrusLewis CapaldiBLACKPINKBENEE, Gus Dapperton21 Savage, Metro BoominZAYNMachine Gun KellyNiackFeid, J Balvin, Justin QuilesChris Brown21 Savage, Metro Boomin21 Savage, Metro Boomin21 Savage, Metro BoominBryson Tiller21 Savage, Metro Boomin21 Savage, Metro Boomin21 Savage, Metro BoominInternet MoneyJoji21 Savage, Metro BoominWhoHeem21 Savage, Metro Boomin21 Savage, Metro BoominJojiJojiJoji, DiploPolo GMachine Gun KellyJojiJojiJojiBea MillerSaweetieJojiJoji, BENEECalvin HarrisJuice WRLD, Polo GMachine Gun KellyHarry NachJack HarlowKendrick Lamar, Jay RockInternet Money, DiploEarth, Wind & FireRegard, RAYEPolo GDamso, HamzaDamsoTaylor SwiftJuice WRLDJuice WRLDLil TeccaDrake6ix9ineDua LipaKygo, Donna SummerAva MaxAva MaxOzuna, Doja Cat, SiaSZA, The Neptunes, Pharrell Williams, Ty Dolla $ignMaroon 5MatuêBonez MCAlex Rose, Rafa PabönLil BabyBonez MC, MaxwellMiley CyrusDoja CatHeadie OneNeaBeyoncé, Megan Thee StallionBig SeanSaweetieITZYTravis ScottMalumaRobin Schulz, WesK/DA, (G)I-DLE, Wolftyla, Bea Miller, League of LegendsMc Zaac, Anitta, TygaPeach Tree RascalsTaylor SwiftBlack Eyed Peas, J BalvinKitschKrieg, Jamule, SFRKygo, Tina TurnerKaty PerryConkarahCordaeJACKBOYS, Travis ScottJowell & Randy, J BalvinAnuel AALady GagaRod WaveJuice WRLDJustin Quiles, Daddy Yankee, El AlfaInternet Money, Gunna, Don Toliver, NAVCapital Bra, CroBTSSam SmithJuice WRLDFeid, Justin QuilesBausa, JujuTaylor SwiftblackbearMustardBTSJason Mraz5 Seconds of SummerTaylor SwiftDua LipaTaylor SwiftRod WavePolo GS1mbaHeadie One, DrakeDua LipaRauw Alejandro, Chencho CorleoneJason Derulo, Puri, JhorrmountainAya NakamuratwocolorsTaylor SwiftKygo, Whitney HoustonJuanfranNLE ChoppaPost MaloneTaylor SwiftTaylor SwiftTaylor SwiftTaylor SwiftDaBabyTaylor SwiftDoja Cat6ix9ineApache 207VIZE, Tom GregoryMegan Thee StallionTaylor SwiftTaylor SwiftTaylor SwiftA$AP FergApache 207Bonez MCFuture, Lil Uzi VertTaylor SwiftJuice WRLDNLE ChoppaJ BalvinEl Alfa, Chael ProduciendoRauw AlejandroTy Dolla $ignJ BalvinBillie EilishJ. ColeCapital Bra, Clueso, KC RebellThe Kid LAROIJuice WRLDOne DirectionUfo361, Sonus030Juice WRLDJuice WRLDJuice WRLDDripReportLil BabyOne DirectionLogicStaySolidRocky, Lil Uzi VertJuice WRLDJuice WRLDJuice WRLDJuice WRLDJuice WRLDTrevor DanielJuice WRLDLil TeccaMyke TowersLucianoBad Bunny6ix9ineLil Nas X, Billy Ray CyrusKid CudiAnuel AA, Daddy Yankee, KAROL G, Ozuna, J BalvinDalex, Lenny Tavárez, Chencho Corleone, Juhn, Dímelo FlowBad Bunny, SechJustin BieberRoddy RicchDoja CatPost MaloneDaBabyDímelo Flow, Arcangel, SechJuice WRLDJuice WRLDJuice WRLDKontra KKanye West, Travis ScottPop SmokeRed Velvet - IRENE & SEULGI6ix9ineAnuel AASam FischerPop SmokeY2K, bbno$Pop SmokePop SmokePop SmokePop SmokePop SmokePop SmokePop SmokePop SmokePop SmokeSleepy Hallow, FousheéTyla YawehPop SmokeBad Bunnyiann diorJhay Cortez, J Balvin, Bad BunnyAnuel AAImagine DragonsRauw Alejandro, Chencho Corleone, KEVVO, Bryant Myers, Lyanno, DalexPost MaloneJourneyBeyoncéMiksu / Macloud, Summer Cem, Luciano, JamuleAva MaxKaty PerryLil BabyLil Uzi VertTWICEMegan Thee StallionBring Me The HorizonJonas BrothersLauvPanic! At The DiscoDrakeDoja CatBoomdabash, Alessandra AmorosoKhalid, DisclosureDon ToliverPashanimBLACKPINKHarry StylesSelena GomezMaroon 5Bad Bunny, Don OmarTygaBonez MCCapital Bra, BozzaAnuel AAA Boogie Wit da HoodieJ. ColeBoshAlida, Robin SchulzLady GagaNLE ChoppaAlexander 23MEDUZA, GoodboysNiackBad Bunny, Daddy YankeePUBLICDaBabyPop Smoke, Rowdy RebelShabloUfo361, CÉLINELil Uzi VertMadison BeerNatalie TaylorNAVBad BunnyBad BunnyKygo, Zara Larsson, TygaCamila CabelloAlec BenjaminPARTYNEXTDOOR, RihannaApache 207XXXTENTACIONKC Rebell, Summer CemSam SmithChildish GambinoRauw Alejandro, FarrukoBad Bunny, Nicky JamShawn MendesJonas BrothersBad Bunny, TainyFutureLil Uzi VertXXXTENTACIONYNW MellyTwenty One PilotsLady GagaLady GagaLady GagaLady GagaLady GagaLady GagaLady GagaLady GagaLady GagaLady GagaLady GagaKygo, Kim PetrasKC Rebell, Summer CemKALIM, Ufo361Lil YachtyLil YachtyBonez MCKygo, Zak AbelApache 207Agust DGunnaThe WeekndGunnaCapital BraGunnaPost MaloneYandel, Bad BunnyJonas BrothersBad Bunny, Zion & LennoxSiaIUHalsey24kGoldnVicetone, Tony IgyThe WeekndTravis ScottTones And IArcangel, Sech, Romeo SantosjxdnSech, Daddy YankeeNicky Jam, Daddy YankeeFutureDrakeFuturePolo G, Stunna 4 Vegas, NLE Choppa, Mike WiLL Made-ItGusttavo LimaMigosPolo GBad BunnyG Herbo, Juice WRLD, Lil Uzi Vert, Chance the RapperTrippie Redd, PARTYNEXTDOORKina, Adriana ProenzaBad BunnyBad BunnyLil TjayBad Bunny, GabrielaBanda MS de Sergio Lizárraga, Snoop DoggCapital Bra, LoredanaBad BunnyDrakeAsheKehlaniTravis Scottbenny blancoYNW MellySam SmithBillie EilishFuture, Drake, Young ThugDrakeDrakeDrakeDrakeDrakeDrakeDrakeDrakeDrakeNAV, GunnaSelena GomezAli GatieUfo361DaBabyAnuel AADrakeCamilo, Evaluna MontanerPlayboi CartiTory LanezRauw Alejandro, Anuel AA, Natti Natasha, Farruko, LunayBROCKHAMPTONShirin DavidTravis ScottKSILil Uzi VertShakira, Anuel AAThe 1975Alan Walker, Ava MaxCamilo, Pedro CapóEllie GouldingG-EazyJ BalvinDaBabyDaBabyDaBabyLil Uzi VertRvssian, Anuel AA, Juice WRLDKygo, Sasha Alex SloanLil YachtyDaBabyKAROL G, Anuel AADominic FikeTory LanezTory LanezBonez MCSamraSam SmithITZYThe Chainsmokers, ILLENIUM, Lennon StellaRod WaveLunay, Myke Towers, Ozuna, Chencho Corleone, Rauw AlejandroPolo G, Stunna 4 VegasSub UrbanLizzoJustin BieberDemi Lovato5 Seconds of SummerBad BunnyThe WeekndLuísa SonzaLil BabyDua LipaBazziDua LipaDua LipaDua LipaThe WeekndThe WeekndDua LipaShiva, Eiffel 65Zuna, Loredana, SRNOThe Weeknd5 Seconds of SummerThe WeekndThe WeekndThe WeekndUfo361Bad Bunny, YaviahJhay Cortez, Anuel AA, J BalvinLittle Mix5 Seconds of SummerThe WeekndThe WeekndJ BalvinJ BalvinJ BalvinJ Balvin, Sky RompiendoLil Uzi VertLil Uzi VertNiall HoranLil Uzi VertJ Balvin, Mr EaziDaBabySelena GomezDardan, Monet192Bad BunnyChristian NodalJhené AikoBad BunnyBad Bunny, Anuel AALil Uzi VertLil Uzi Vert, 21 SavageDon ToliverLil Uzi VertBad Bunny, Duki, Pablo Chill-ELil Uzi VertNinhoBad Bunny, Ñengo FlowLil Uzi VertLil Uzi VertBad BunnyLil Uzi VertBad Bunny, MoraLil Uzi VertNiall HoranSZA, Justin TimberlakeNicky Jam, Anuel AATygaLil Uzi VertLauvLil Uzi VertLil Uzi VertLil Uzi VertLil Uzi VertLil Uzi VertBTSTones And ITainyBad BunnyUfo361Henrique & JulianoLil Uzi VertLil Uzi VertLil Uzi VertLil Uzi VertLil Uzi VertLil Uzi VertLil Uzi VertResidenteLil Uzi VertLil Uzi VertBTSBad Bunny, Kendo Kaponi, ArcangelLauvLil BabyGunnaBazziLauv, Troye SivanA Boogie Wit da HoodieMyke TowersBad Bunny, Myke TowersDaddy Yankee, SechEd SheeranPost MaloneLauvLunay, Ozuna, Anuel AASelena GomezDaBabyLauv, LANYLil Uzi VertLil BabyLil BabyLil BabyBTSApache 207Dalex, Lenny Tavárez, Anitta, Natti Natasha, Farruko, Justin QuilesArcangel, Bad BunnyDaddy YankeeLil Uzi VertTOKYO’S REVENGEStormzyFutureBTSCapital Bra, SamraMartin GarrixblackbearJ Balvin, Bad BunnyTaylor SwiftRich Music LTD, Sech, Dalex, Justin Quiles, Lenny Tavárez, Feid, Wisin, ZionLunay, Daddy Yankee, Bad BunnySHAEDLizzoBillie EilishBTSBTSBTSBTSBTSBTSBTSBTSBTSBTSThiaguinho MT, Mila, JS o Mão de OuroRich Music LTD, Sech, Dalex, Justin Quiles, Lenny Tavárez, FeidEminemBillie EilishPEDRO SAMPAIO, Felipe Original, JS o Mão de OuroK CAMPSech, OzunaMajor Lazer, DiploUfo361Reik, J Balvin, Lalo EbrattBillie EilishDalex, SechMigos, Travis Scott, Young ThugJustin BieberJustin BieberJustin BieberJustin BieberJustin BieberJustin BieberJustin BieberTame ImpalaJustin BieberJustin BieberLucianoJustin BieberTame ImpalaJustin Bieber5 Seconds of SummerA Boogie Wit da HoodieJustin BieberKygo, Sandro CavazzaJoker Bra, VIZETame ImpalaMac MillerBillie EilishTaylor SwiftTame ImpalaJustin BieberBillie EilishSam SmithJustin Bieber, QuavoNicki MinajAnt SaundersAnne-MarieTravis ScottLizzoLil WayneJustin Bieber, KehlaniROSALÍA, OzunaJustin Quiles, Natti Natasha, FarrukoTyler, The CreatorPiso 21, Christian NodalDJ Snake, J BalvinRed VelvetDaBabyROSALÍA, J Balvin, El GuinchoJonas BrothersKhalidKhalidTravis Scott, Young ThugSamraDaddy Yankee, SnowJ. ColeSech, Ozuna, Anuel AA, Darell, Nicky JamArizona ZervasA Boogie Wit da HoodieEminemSamraMatthew WilderJuju, Loredana, Miksu / MacloudHalseyKSIRiton, Oliver HeldensShakiraCamila CabelloMeek MillTaylor SwiftLil Nas XBillie EilishJ. Cole, Young ThugYNW MellyEminemEminemMac MillerHenrique & JulianoEminemGzuzEminemSamra, ELIFMegan Thee StallionSelena GomezMurda, EzhelJuice WRLDMalumaSam FeldtEminemEminemMac MillerMac MillerEminemMac MillerEminemEminemEminemEminemEminemMac MillerEminemMac MillerEminemEminemEminemHalseyMac MillerMac MillerMac MillerUfo361, FutureMac MillerGambiMaes, BoobaSelena GomezSelena GomezSelena GomezSelena GomezSelena GomezKhalidNiall HoranIdina Menzel, AURORASelena GomezSelena GomezLil MoseyPost MaloneRoddy RicchRoddy RicchMegan Thee StallionMabelTrippie Redd, DaBabyPedro Capó, FarrukoSelena GomezSelena GomezAnne-MarieDJ SnakeThe Chainsmokers, KygoJACKBOYS, Sheck WesDon ToliverJACKBOYS, Travis ScottFrench Montana24kGoldnApache 207Katy PerryCalvin HarrisOzunaSHAED, ZAYNJACKBOYS, Pop Smoke, Travis ScottDoja CatJACKBOYSAnitta, Lexa, Luísa SonzaLil Nas XJuice WRLDGradur, Heuss L'enfoiréDua LipaJorge & MateusCamila CabelloDadá Boladão, Tati Zaqui, OIKTaylor Swift to numeric" ] } ], "source": [ "df2.apply(lambda s: s-s.mean(), axis=0)" ] }, { "cell_type": "code", "execution_count": 39, "metadata": { "cell_id": "816efbd566b04e6c9d5e830d2749ffa3", "deepnote_cell_height": 600, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 37, "execution_start": 1650659427184, "source_hash": "e897a808", "tags": [] }, "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
DanceabilityEnergySpeechinessAcousticnessValenceDuration (ms)
00.0240030.166505-0.073256-0.1216950.07429613619.183172
1-0.0989970.130505-0.075356-0.210395-0.036704-56134.816828
2-0.1269970.0305050.0303440.0863050.173296-19793.816828
30.1180030.263505-0.088856-0.2017950.07629633100.183172
40.0460030.070505-0.062156-0.2283950.37929614059.183172
.....................
15510.0720030.066505-0.054256-0.2460850.09329611379.183172
1552-0.1619970.236505-0.038556-0.0086950.199296-16010.816828
15530.075003-0.110495-0.093656-0.064695-0.12070419366.183172
15540.142003-0.083495-0.0649560.0003050.366296-45156.816828
1555-0.241997-0.030495-0.0596560.184305-0.09270423366.183172
\n", "

1545 rows × 6 columns

\n", "
" ], "text/plain": [ " Danceability Energy Speechiness Acousticness Valence \\\n", "0 0.024003 0.166505 -0.073256 -0.121695 0.074296 \n", "1 -0.098997 0.130505 -0.075356 -0.210395 -0.036704 \n", "2 -0.126997 0.030505 0.030344 0.086305 0.173296 \n", "3 0.118003 0.263505 -0.088856 -0.201795 0.076296 \n", "4 0.046003 0.070505 -0.062156 -0.228395 0.379296 \n", "... ... ... ... ... ... \n", "1551 0.072003 0.066505 -0.054256 -0.246085 0.093296 \n", "1552 -0.161997 0.236505 -0.038556 -0.008695 0.199296 \n", "1553 0.075003 -0.110495 -0.093656 -0.064695 -0.120704 \n", "1554 0.142003 -0.083495 -0.064956 0.000305 0.366296 \n", "1555 -0.241997 -0.030495 -0.059656 0.184305 -0.092704 \n", "\n", " Duration (ms) \n", "0 13619.183172 \n", "1 -56134.816828 \n", "2 -19793.816828 \n", "3 33100.183172 \n", "4 14059.183172 \n", "... ... \n", "1551 11379.183172 \n", "1552 -16010.816828 \n", "1553 19366.183172 \n", "1554 -45156.816828 \n", "1555 23366.183172 \n", "\n", "[1545 rows x 6 columns]" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df2[numcols].apply(lambda s: s-s.mean(), axis=0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here we change the values in those numeric columns." ] }, { "cell_type": "code", "execution_count": 40, "metadata": { "cell_id": "f9714bcda49f4a88b34ba5b727a80bee", "deepnote_cell_height": 81, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 4, "execution_start": 1650659464370, "source_hash": "4308ce5e", "tags": [] }, "outputs": [], "source": [ "df2[numcols] = df2[numcols].apply(lambda s: s-s.mean(), axis=0)" ] }, { "cell_type": "code", "execution_count": 41, "metadata": { "cell_id": "b1fe1518fd4a4fe2a76e76b953e51301", "deepnote_cell_height": 233.375, "deepnote_cell_type": "code", "deepnote_output_heights": [ 136.375 ], "deepnote_to_be_reexecuted": false, "execution_millis": 5, "execution_start": 1650659612777, "source_hash": "e1b96537", "tags": [] }, "outputs": [ { "data": { "text/plain": [ "Danceability -8.738066e-17\n", "Energy -5.058880e-17\n", "Speechiness 1.149746e-18\n", "Acousticness 3.219287e-17\n", "Valence 1.034771e-17\n", "Duration (ms) -6.630776e-12\n", "dtype: float64" ] }, "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df2[numcols].mean(axis=0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Just for practice with `apply`, here we do the same thing using a lambda function." ] }, { "cell_type": "code", "execution_count": 42, "metadata": { "cell_id": "59d6132769574daf82acb5bc2d90930d", "deepnote_cell_height": 233.375, "deepnote_cell_type": "code", "deepnote_output_heights": [ 136.375 ], "deepnote_to_be_reexecuted": false, "execution_millis": 3, "execution_start": 1650659583759, "source_hash": "b45d52a8", "tags": [] }, "outputs": [ { "data": { "text/plain": [ "Danceability -8.738066e-17\n", "Energy -5.058880e-17\n", "Speechiness 1.149746e-18\n", "Acousticness 3.219287e-17\n", "Valence 1.034771e-17\n", "Duration (ms) -6.630776e-12\n", "dtype: float64" ] }, "execution_count": 42, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df2[numcols].apply(lambda s: s.mean(), axis=0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "All of the entries are the same in `df1` and `df2`, except for the top-left entry in `df1` which we changed in a previous demonstration." ] }, { "cell_type": "code", "execution_count": 43, "metadata": { "cell_id": "256110a1eee04778b1de1943e8222def", "deepnote_cell_height": 600, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 40, "execution_start": 1650659476643, "source_hash": "61b7822", "tags": [] }, "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", " \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", "
ArtistSong NameWeek of Highest ChartingDanceabilityEnergySpeechinessAcousticnessValenceDuration (ms)
0FalseTrueTrueTrueTrueTrueTrueTrueTrue
1TrueTrueTrueTrueTrueTrueTrueTrueTrue
2TrueTrueTrueTrueTrueTrueTrueTrueTrue
3TrueTrueTrueTrueTrueTrueTrueTrueTrue
4TrueTrueTrueTrueTrueTrueTrueTrueTrue
..............................
1551TrueTrueTrueTrueTrueTrueTrueTrueTrue
1552TrueTrueTrueTrueTrueTrueTrueTrueTrue
1553TrueTrueTrueTrueTrueTrueTrueTrueTrue
1554TrueTrueTrueTrueTrueTrueTrueTrueTrue
1555TrueTrueTrueTrueTrueTrueTrueTrueTrue
\n", "

1545 rows × 9 columns

\n", "
" ], "text/plain": [ " Artist Song Name Week of Highest Charting Danceability Energy \\\n", "0 False True True True True \n", "1 True True True True True \n", "2 True True True True True \n", "3 True True True True True \n", "4 True True True True True \n", "... ... ... ... ... ... \n", "1551 True True True True True \n", "1552 True True True True True \n", "1553 True True True True True \n", "1554 True True True True True \n", "1555 True True True True True \n", "\n", " Speechiness Acousticness Valence Duration (ms) \n", "0 True True True True \n", "1 True True True True \n", "2 True True True True \n", "3 True True True True \n", "4 True True True True \n", "... ... ... ... ... \n", "1551 True True True True \n", "1552 True True True True \n", "1553 True True True True \n", "1554 True True True True \n", "1555 True True True True \n", "\n", "[1545 rows x 9 columns]" ] }, "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df1 == df2" ] }, { "cell_type": "markdown", "metadata": { "cell_id": "ecb9edbbc9c348cf9669d988b3a30ddf", "deepnote_cell_height": 257.375, "deepnote_cell_type": "markdown", "tags": [] }, "source": [ "## Rescaling 3: using scikit-learn\n", "\n", "We can use the Python library scikit-learn to rescale these numeric columns.\n", "\n", "* Make a copy of `df` called `df3`.\n", "* Instantiate a `StandardScaler` object that will rescale mean but not standard deviation. Call the object `scaler`.\n", "* Fit `scaler` using the columns listed in `numcols`.\n", "* Transform those columns and put the result into `df3`." ] }, { "cell_type": "code", "execution_count": 44, "metadata": { "cell_id": "14a03b3edca948a5a1a7e61dcbad17a4", "deepnote_cell_height": 81, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 1, "execution_start": 1650659707862, "source_hash": "e3b40650", "tags": [] }, "outputs": [], "source": [ "df3 = df.copy()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Instead of importing all of scikit-learn, we will usually just import the specific tools we will need. In this case, we are importing only `StandardScaler` from the sklearn.preprocessing module." ] }, { "cell_type": "code", "execution_count": 45, "metadata": { "cell_id": "c04e5269b0d542c5af9ab07e63d3487d", "deepnote_cell_height": 81, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 1, "execution_start": 1650659795147, "source_hash": "866b8212", "tags": [] }, "outputs": [], "source": [ "from sklearn.preprocessing import StandardScaler" ] }, { "cell_type": "code", "execution_count": 46, "metadata": { "cell_id": "e6e96c21b0694913aac18372cc403ac9", "deepnote_cell_height": 701, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 10, "execution_start": 1650659903404, "source_hash": "c6f42df1", "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Help on class StandardScaler in module sklearn.preprocessing._data:\n", "\n", "class StandardScaler(sklearn.base._OneToOneFeatureMixin, sklearn.base.TransformerMixin, sklearn.base.BaseEstimator)\n", " | StandardScaler(*, copy=True, with_mean=True, with_std=True)\n", " | \n", " | Standardize features by removing the mean and scaling to unit variance.\n", " | \n", " | The standard score of a sample `x` is calculated as:\n", " | \n", " | z = (x - u) / s\n", " | \n", " | where `u` is the mean of the training samples or zero if `with_mean=False`,\n", " | and `s` is the standard deviation of the training samples or one if\n", " | `with_std=False`.\n", " | \n", " | Centering and scaling happen independently on each feature by computing\n", " | the relevant statistics on the samples in the training set. Mean and\n", " | standard deviation are then stored to be used on later data using\n", " | :meth:`transform`.\n", " | \n", " | Standardization of a dataset is a common requirement for many\n", " | machine learning estimators: they might behave badly if the\n", " | individual features do not more or less look like standard normally\n", " | distributed data (e.g. Gaussian with 0 mean and unit variance).\n", " | \n", " | For instance many elements used in the objective function of\n", " | a learning algorithm (such as the RBF kernel of Support Vector\n", " | Machines or the L1 and L2 regularizers of linear models) assume that\n", " | all features are centered around 0 and have variance in the same\n", " | order. If a feature has a variance that is orders of magnitude larger\n", " | that others, it might dominate the objective function and make the\n", " | estimator unable to learn from other features correctly as expected.\n", " | \n", " | This scaler can also be applied to sparse CSR or CSC matrices by passing\n", " | `with_mean=False` to avoid breaking the sparsity structure of the data.\n", " | \n", " | Read more in the :ref:`User Guide `.\n", " | \n", " | Parameters\n", " | ----------\n", " | copy : bool, default=True\n", " | If False, try to avoid a copy and do inplace scaling instead.\n", " | This is not guaranteed to always work inplace; e.g. if the data is\n", " | not a NumPy array or scipy.sparse CSR matrix, a copy may still be\n", " | returned.\n", " | \n", " | with_mean : bool, default=True\n", " | If True, center the data before scaling.\n", " | This does not work (and will raise an exception) when attempted on\n", " | sparse matrices, because centering them entails building a dense\n", " | matrix which in common use cases is likely to be too large to fit in\n", " | memory.\n", " | \n", " | with_std : bool, default=True\n", " | If True, scale the data to unit variance (or equivalently,\n", " | unit standard deviation).\n", " | \n", " | Attributes\n", " | ----------\n", " | scale_ : ndarray of shape (n_features,) or None\n", " | Per feature relative scaling of the data to achieve zero mean and unit\n", " | variance. Generally this is calculated using `np.sqrt(var_)`. If a\n", " | variance is zero, we can't achieve unit variance, and the data is left\n", " | as-is, giving a scaling factor of 1. `scale_` is equal to `None`\n", " | when `with_std=False`.\n", " | \n", " | .. versionadded:: 0.17\n", " | *scale_*\n", " | \n", " | mean_ : ndarray of shape (n_features,) or None\n", " | The mean value for each feature in the training set.\n", " | Equal to ``None`` when ``with_mean=False``.\n", " | \n", " | var_ : ndarray of shape (n_features,) or None\n", " | The variance for each feature in the training set. Used to compute\n", " | `scale_`. Equal to ``None`` when ``with_std=False``.\n", " | \n", " | n_features_in_ : int\n", " | Number of features seen during :term:`fit`.\n", " | \n", " | .. versionadded:: 0.24\n", " | \n", " | feature_names_in_ : ndarray of shape (`n_features_in_`,)\n", " | Names of features seen during :term:`fit`. Defined only when `X`\n", " | has feature names that are all strings.\n", " | \n", " | .. versionadded:: 1.0\n", " | \n", " | n_samples_seen_ : int or ndarray of shape (n_features,)\n", " | The number of samples processed by the estimator for each feature.\n", " | If there are no missing samples, the ``n_samples_seen`` will be an\n", " | integer, otherwise it will be an array of dtype int. If\n", " | `sample_weights` are used it will be a float (if no missing data)\n", " | or an array of dtype float that sums the weights seen so far.\n", " | Will be reset on new calls to fit, but increments across\n", " | ``partial_fit`` calls.\n", " | \n", " | See Also\n", " | --------\n", " | scale : Equivalent function without the estimator API.\n", " | \n", " | :class:`~sklearn.decomposition.PCA` : Further removes the linear\n", " | correlation across features with 'whiten=True'.\n", " | \n", " | Notes\n", " | -----\n", " | NaNs are treated as missing values: disregarded in fit, and maintained in\n", " | transform.\n", " | \n", " | We use a biased estimator for the standard deviation, equivalent to\n", " | `numpy.std(x, ddof=0)`. Note that the choice of `ddof` is unlikely to\n", " | affect model performance.\n", " | \n", " | For a comparison of the different scalers, transformers, and normalizers,\n", " | see :ref:`examples/preprocessing/plot_all_scaling.py\n", " | `.\n", " | \n", " | Examples\n", " | --------\n", " | >>> from sklearn.preprocessing import StandardScaler\n", " | >>> data = [[0, 0], [0, 0], [1, 1], [1, 1]]\n", " | >>> scaler = StandardScaler()\n", " | >>> print(scaler.fit(data))\n", " | StandardScaler()\n", " | >>> print(scaler.mean_)\n", " | [0.5 0.5]\n", " | >>> print(scaler.transform(data))\n", " | [[-1. -1.]\n", " | [-1. -1.]\n", " | [ 1. 1.]\n", " | [ 1. 1.]]\n", " | >>> print(scaler.transform([[2, 2]]))\n", " | [[3. 3.]]\n", " | \n", " | Method resolution order:\n", " | StandardScaler\n", " | sklearn.base._OneToOneFeatureMixin\n", " | sklearn.base.TransformerMixin\n", " | sklearn.base.BaseEstimator\n", " | builtins.object\n", " | \n", " | Methods defined here:\n", " | \n", " | __init__(self, *, copy=True, with_mean=True, with_std=True)\n", " | Initialize self. See help(type(self)) for accurate signature.\n", " | \n", " | fit(self, X, y=None, sample_weight=None)\n", " | Compute the mean and std to be used for later scaling.\n", " | \n", " | Parameters\n", " | ----------\n", " | X : {array-like, sparse matrix} of shape (n_samples, n_features)\n", " | The data used to compute the mean and standard deviation\n", " | used for later scaling along the features axis.\n", " | \n", " | y : None\n", " | Ignored.\n", " | \n", " | sample_weight : array-like of shape (n_samples,), default=None\n", " | Individual weights for each sample.\n", " | \n", " | .. versionadded:: 0.24\n", " | parameter *sample_weight* support to StandardScaler.\n", " | \n", " | Returns\n", " | -------\n", " | self : object\n", " | Fitted scaler.\n", " | \n", " | inverse_transform(self, X, copy=None)\n", " | Scale back the data to the original representation.\n", " | \n", " | Parameters\n", " | ----------\n", " | X : {array-like, sparse matrix} of shape (n_samples, n_features)\n", " | The data used to scale along the features axis.\n", " | copy : bool, default=None\n", " | Copy the input X or not.\n", " | \n", " | Returns\n", " | -------\n", " | X_tr : {ndarray, sparse matrix} of shape (n_samples, n_features)\n", " | Transformed array.\n", " | \n", " | partial_fit(self, X, y=None, sample_weight=None)\n", " | Online computation of mean and std on X for later scaling.\n", " | \n", " | All of X is processed as a single batch. This is intended for cases\n", " | when :meth:`fit` is not feasible due to very large number of\n", " | `n_samples` or because X is read from a continuous stream.\n", " | \n", " | The algorithm for incremental mean and std is given in Equation 1.5a,b\n", " | in Chan, Tony F., Gene H. Golub, and Randall J. LeVeque. \"Algorithms\n", " | for computing the sample variance: Analysis and recommendations.\"\n", " | The American Statistician 37.3 (1983): 242-247:\n", " | \n", " | Parameters\n", " | ----------\n", " | X : {array-like, sparse matrix} of shape (n_samples, n_features)\n", " | The data used to compute the mean and standard deviation\n", " | used for later scaling along the features axis.\n", " | \n", " | y : None\n", " | Ignored.\n", " | \n", " | sample_weight : array-like of shape (n_samples,), default=None\n", " | Individual weights for each sample.\n", " | \n", " | .. versionadded:: 0.24\n", " | parameter *sample_weight* support to StandardScaler.\n", " | \n", " | Returns\n", " | -------\n", " | self : object\n", " | Fitted scaler.\n", " | \n", " | transform(self, X, copy=None)\n", " | Perform standardization by centering and scaling.\n", " | \n", " | Parameters\n", " | ----------\n", " | X : {array-like, sparse matrix of shape (n_samples, n_features)\n", " | The data used to scale along the features axis.\n", " | copy : bool, default=None\n", " | Copy the input X or not.\n", " | \n", " | Returns\n", " | -------\n", " | X_tr : {ndarray, sparse matrix} of shape (n_samples, n_features)\n", " | Transformed array.\n", " | \n", " | ----------------------------------------------------------------------\n", " | Methods inherited from sklearn.base._OneToOneFeatureMixin:\n", " | \n", " | get_feature_names_out(self, input_features=None)\n", " | Get output feature names for transformation.\n", " | \n", " | Parameters\n", " | ----------\n", " | input_features : array-like of str or None, default=None\n", " | Input features.\n", " | \n", " | - If `input_features` is `None`, then `feature_names_in_` is\n", " | used as feature names in. If `feature_names_in_` is not defined,\n", " | then names are generated: `[x0, x1, ..., x(n_features_in_)]`.\n", " | - If `input_features` is an array-like, then `input_features` must\n", " | match `feature_names_in_` if `feature_names_in_` is defined.\n", " | \n", " | Returns\n", " | -------\n", " | feature_names_out : ndarray of str objects\n", " | Same as input features.\n", " | \n", " | ----------------------------------------------------------------------\n", " | Data descriptors inherited from sklearn.base._OneToOneFeatureMixin:\n", " | \n", " | __dict__\n", " | dictionary for instance variables (if defined)\n", " | \n", " | __weakref__\n", " | list of weak references to the object (if defined)\n", " | \n", " | ----------------------------------------------------------------------\n", " | Methods inherited from sklearn.base.TransformerMixin:\n", " | \n", " | fit_transform(self, X, y=None, **fit_params)\n", " | Fit to data, then transform it.\n", " | \n", " | Fits transformer to `X` and `y` with optional parameters `fit_params`\n", " | and returns a transformed version of `X`.\n", " | \n", " | Parameters\n", " | ----------\n", " | X : array-like of shape (n_samples, n_features)\n", " | Input samples.\n", " | \n", " | y : array-like of shape (n_samples,) or (n_samples, n_outputs), default=None\n", " | Target values (None for unsupervised transformations).\n", " | \n", " | **fit_params : dict\n", " | Additional fit parameters.\n", " | \n", " | Returns\n", " | -------\n", " | X_new : ndarray array of shape (n_samples, n_features_new)\n", " | Transformed array.\n", " | \n", " | ----------------------------------------------------------------------\n", " | Methods inherited from sklearn.base.BaseEstimator:\n", " | \n", " | __getstate__(self)\n", " | \n", " | __repr__(self, N_CHAR_MAX=700)\n", " | Return repr(self).\n", " | \n", " | __setstate__(self, state)\n", " | \n", " | get_params(self, deep=True)\n", " | Get parameters for this estimator.\n", " | \n", " | Parameters\n", " | ----------\n", " | deep : bool, default=True\n", " | If True, will return the parameters for this estimator and\n", " | contained subobjects that are estimators.\n", " | \n", " | Returns\n", " | -------\n", " | params : dict\n", " | Parameter names mapped to their values.\n", " | \n", " | set_params(self, **params)\n", " | Set the parameters of this estimator.\n", " | \n", " | The method works on simple estimators as well as on nested objects\n", " | (such as :class:`~sklearn.pipeline.Pipeline`). The latter have\n", " | parameters of the form ``__`` so that it's\n", " | possible to update each component of a nested object.\n", " | \n", " | Parameters\n", " | ----------\n", " | **params : dict\n", " | Estimator parameters.\n", " | \n", " | Returns\n", " | -------\n", " | self : estimator instance\n", " | Estimator instance.\n", "\n" ] } ], "source": [ "help(StandardScaler)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The bad news is that working with scikit-learn takes some practice, partially because it is very object-oriented in its style. The good news is that the different tools from scikit-learn mostly work very similarly (they have a very similar syntax to each other)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here we instantiate a StandardScaler object." ] }, { "cell_type": "code", "execution_count": 47, "metadata": { "cell_id": "f3bc071c16884366ae5eaeb9542b211b", "deepnote_cell_height": 135, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 2, "execution_start": 1650659990746, "source_hash": "60614876", "tags": [] }, "outputs": [], "source": [ "# exact same as `scaler = StandardScaler(with_std=False)`\n", "scaler = StandardScaler(with_mean=True, with_std=False)" ] }, { "cell_type": "code", "execution_count": 48, "metadata": { "cell_id": "f1ad6124ff6e4006a5c0e29a27bed7e4", "deepnote_cell_height": 118.1875, "deepnote_cell_type": "code", "deepnote_output_heights": [ 21.1875 ], "deepnote_to_be_reexecuted": false, "execution_millis": 6, "execution_start": 1650659995995, "source_hash": "3704af6a", "tags": [] }, "outputs": [ { "data": { "text/plain": [ "sklearn.preprocessing._data.StandardScaler" ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(scaler)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Many of the objects we work with from scikit-learn have a `fit` method and either a `predict` method or a `transform` method. Here is an example of using the `fit` and `transform` methods of `scaler`." ] }, { "cell_type": "code", "execution_count": 49, "metadata": { "cell_id": "b88628d7d29948c1a97d79d5ff1db8fc", "deepnote_cell_height": 118.1875, "deepnote_cell_type": "code", "deepnote_output_heights": [ 21.1875 ], "deepnote_to_be_reexecuted": false, "execution_millis": 9, "execution_start": 1650660094985, "source_hash": "e1b55986", "tags": [] }, "outputs": [ { "data": { "text/plain": [ "StandardScaler(with_std=False)" ] }, "execution_count": 49, "metadata": {}, "output_type": "execute_result" } ], "source": [ "scaler.fit(df[numcols])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This `scaler` has lots of different methods and attributes. (Typically you should ignore the ones that begin and end with double underscores. These are called \"dunder\" methods, and usually we do not use them directly.)" ] }, { "cell_type": "code", "execution_count": 50, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['__class__',\n", " '__delattr__',\n", " '__dict__',\n", " '__dir__',\n", " '__doc__',\n", " '__eq__',\n", " '__format__',\n", " '__ge__',\n", " '__getattribute__',\n", " '__getstate__',\n", " '__gt__',\n", " '__hash__',\n", " '__init__',\n", " '__init_subclass__',\n", " '__le__',\n", " '__lt__',\n", " '__module__',\n", " '__ne__',\n", " '__new__',\n", " '__reduce__',\n", " '__reduce_ex__',\n", " '__repr__',\n", " '__setattr__',\n", " '__setstate__',\n", " '__sizeof__',\n", " '__str__',\n", " '__subclasshook__',\n", " '__weakref__',\n", " '_check_feature_names',\n", " '_check_n_features',\n", " '_get_param_names',\n", " '_get_tags',\n", " '_more_tags',\n", " '_repr_html_',\n", " '_repr_html_inner',\n", " '_repr_mimebundle_',\n", " '_reset',\n", " '_validate_data',\n", " 'copy',\n", " 'feature_names_in_',\n", " 'fit',\n", " 'fit_transform',\n", " 'get_feature_names_out',\n", " 'get_params',\n", " 'inverse_transform',\n", " 'mean_',\n", " 'n_features_in_',\n", " 'n_samples_seen_',\n", " 'partial_fit',\n", " 'scale_',\n", " 'set_params',\n", " 'transform',\n", " 'var_',\n", " 'with_mean',\n", " 'with_std']" ] }, "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dir(scaler)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now that we have fit `scaler`, the `mean_` attribute holds the mean values from the columns." ] }, { "cell_type": "code", "execution_count": 51, "metadata": { "cell_id": "d706548a11654a839645cb1898ba94fc", "deepnote_cell_height": 137.375, "deepnote_cell_type": "code", "deepnote_output_heights": [ 40.390625 ], "deepnote_to_be_reexecuted": false, "execution_millis": 25, "execution_start": 1650660342581, "source_hash": "1083c49d", "tags": [] }, "outputs": [ { "data": { "text/plain": [ "array([6.89996764e-01, 6.33495146e-01, 1.23655728e-01, 2.48694503e-01,\n", " 5.14703819e-01, 1.97940817e+05])" ] }, "execution_count": 51, "metadata": {}, "output_type": "execute_result" } ], "source": [ "scaler.mean_" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we use the `transform` method." ] }, { "cell_type": "code", "execution_count": 52, "metadata": { "cell_id": "740314dac57646e0a1cc26007989b564", "deepnote_cell_height": 81, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 5, "execution_start": 1650660118087, "source_hash": "ff91ffb1", "tags": [] }, "outputs": [], "source": [ "df3[numcols] = scaler.transform(df[numcols])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now the numeric columns of `df3` all have means very close to zero." ] }, { "cell_type": "code", "execution_count": 53, "metadata": { "cell_id": "634a368a63664d8ba4ac9716c3d85f66", "deepnote_cell_height": 233.375, "deepnote_cell_type": "code", "deepnote_output_heights": [ 136.375 ], "deepnote_to_be_reexecuted": false, "execution_millis": 15, "execution_start": 1650660196827, "source_hash": "621dd69", "tags": [] }, "outputs": [ { "data": { "text/plain": [ "Danceability -8.738066e-17\n", "Energy -5.058880e-17\n", "Speechiness 1.149746e-18\n", "Acousticness 3.219287e-17\n", "Valence 1.034771e-17\n", "Duration (ms) -6.630776e-12\n", "dtype: float64" ] }, "execution_count": 53, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df3[numcols].mean(axis=0)" ] }, { "cell_type": "code", "execution_count": 54, "metadata": {}, "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", " \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", "
ArtistSong NameWeek of Highest ChartingDanceabilityEnergySpeechinessAcousticnessValenceDuration (ms)
0TrueTrueTrueTrueTrueTrueTrueTrueTrue
1TrueTrueTrueTrueTrueTrueTrueTrueTrue
2TrueTrueTrueTrueTrueTrueTrueTrueTrue
3TrueTrueTrueTrueTrueTrueTrueTrueTrue
4TrueTrueTrueTrueTrueTrueTrueTrueTrue
..............................
1551TrueTrueTrueTrueTrueTrueTrueTrueTrue
1552TrueTrueTrueTrueTrueTrueTrueTrueTrue
1553TrueTrueTrueTrueTrueTrueTrueTrueTrue
1554TrueTrueTrueTrueTrueTrueTrueTrueTrue
1555TrueTrueTrueTrueTrueTrueTrueTrueTrue
\n", "

1545 rows × 9 columns

\n", "
" ], "text/plain": [ " Artist Song Name Week of Highest Charting Danceability Energy \\\n", "0 True True True True True \n", "1 True True True True True \n", "2 True True True True True \n", "3 True True True True True \n", "4 True True True True True \n", "... ... ... ... ... ... \n", "1551 True True True True True \n", "1552 True True True True True \n", "1553 True True True True True \n", "1554 True True True True True \n", "1555 True True True True True \n", "\n", " Speechiness Acousticness Valence Duration (ms) \n", "0 True True True True \n", "1 True True True True \n", "2 True True True True \n", "3 True True True True \n", "4 True True True True \n", "... ... ... ... ... \n", "1551 True True True True \n", "1552 True True True True \n", "1553 True True True True \n", "1554 True True True True \n", "1555 True True True True \n", "\n", "[1545 rows x 9 columns]" ] }, "execution_count": 54, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df2 == df3" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "It looks like these values are all equal. Are they?" ] }, { "cell_type": "code", "execution_count": 55, "metadata": { "cell_id": "c2a17e8eb9804233a8ecf3dc040bf0ee", "deepnote_cell_height": 290.9375, "deepnote_cell_type": "code", "deepnote_output_heights": [ 193.953125 ], "deepnote_to_be_reexecuted": false, "execution_millis": 472, "execution_start": 1650660251462, "source_hash": "cb4eb6b8", "tags": [] }, "outputs": [ { "data": { "text/plain": [ "Artist True\n", "Song Name True\n", "Week of Highest Charting True\n", "Danceability True\n", "Energy True\n", "Speechiness True\n", "Acousticness True\n", "Valence True\n", "Duration (ms) True\n", "dtype: bool" ] }, "execution_count": 55, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(df2 == df3).all()" ] }, { "cell_type": "code", "execution_count": 56, "metadata": { "cell_id": "145510121ca6411d9a76483721984d64", "deepnote_cell_height": 290.9375, "deepnote_cell_type": "code", "deepnote_output_heights": [ 193.953125 ], "deepnote_to_be_reexecuted": false, "execution_millis": 10, "execution_start": 1650660232288, "source_hash": "d80d9d23", "tags": [] }, "outputs": [ { "data": { "text/plain": [ "Artist True\n", "Song Name True\n", "Week of Highest Charting True\n", "Danceability True\n", "Energy True\n", "Speechiness True\n", "Acousticness True\n", "Valence True\n", "Duration (ms) True\n", "dtype: bool" ] }, "execution_count": 56, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(df2 == df3).all(axis=0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here we make a new StandardScaler object, this time using the default values, which indicate `scaler2` should store both the `mean` and the `std` from the numeric columns." ] }, { "cell_type": "code", "execution_count": 57, "metadata": { "cell_id": "f11b10d5ce184870829521ae3a58a01c", "deepnote_cell_height": 99, "deepnote_cell_type": "code", "deepnote_to_be_reexecuted": false, "execution_millis": 0, "execution_start": 1650660464717, "source_hash": "bfe4866a", "tags": [] }, "outputs": [], "source": [ "# same as scaler2 = StandardScaler()\n", "scaler2 = StandardScaler(with_mean=True, with_std=True)" ] }, { "cell_type": "code", "execution_count": 58, "metadata": { "cell_id": "32cad3bdcaa74373b007bf5e53733108", "deepnote_cell_height": 118.1875, "deepnote_cell_type": "code", "deepnote_output_heights": [ 21.1875 ], "deepnote_to_be_reexecuted": false, "execution_millis": 623, "execution_start": 1650660488975, "source_hash": "c55a8044", "tags": [] }, "outputs": [ { "data": { "text/plain": [ "StandardScaler()" ] }, "execution_count": 58, "metadata": {}, "output_type": "execute_result" } ], "source": [ "scaler2.fit(df3[numcols])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Because `scaler2` was fit using a DataFrame where the mean of the numeric columns was already (approximately) zero, the `mean_` attribute of `scaler2` will contain values close to 0." ] }, { "cell_type": "code", "execution_count": 59, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([-8.73806601e-17, -5.05888032e-17, 1.14974553e-18, 3.21928748e-17,\n", " 1.03477097e-17, -6.63077561e-12])" ] }, "execution_count": 59, "metadata": {}, "output_type": "execute_result" } ], "source": [ "scaler2.mean_" ] } ], "metadata": { "deepnote": {}, "deepnote_execution_queue": [], "deepnote_notebook_id": "0afc8587-e988-4220-97cd-f40a5709326a", "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.12" } }, "nbformat": 4, "nbformat_minor": 2 }