From ef489b7d9f5a52e46e8771881b6b23374bc521f6 Mon Sep 17 00:00:00 2001 From: HA TRAN Date: Wed, 25 Nov 2020 13:13:53 +1100 Subject: [PATCH] change the approach of creating new labels --- just-pandas-things.ipynb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/just-pandas-things.ipynb b/just-pandas-things.ipynb index 062d1e2..040d809 100644 --- a/just-pandas-things.ipynb +++ b/just-pandas-things.ipynb @@ -1807,8 +1807,8 @@ "\n", "def company_type(x):\n", " hardware_companies = set([\"Orange\", \"Dell\", \"IBM\", \"Siemens\"])\n", - " return \"Hardware\" if x[\"Company\"] in hardware_companies else \"Software\"\n", - "df[\"Type\"] = df.apply(lambda x: company_type(x), axis=1)\n", + " return \"Hardware\" if x in hardware_companies else \"Software\"\n", + "df[\"Type\"] = df[\"Company\"].apply(company_type)\n", "\n", "# Setting \"Type\" to be labels. We call \"\"\n", "df = df.set_index(\"Type\")\n", @@ -3380,7 +3380,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.10" + "version": "3.7.5" }, "varInspector": { "cols": { @@ -3413,5 +3413,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 }