Browse Source

object -> category

Fabian Peter Hammerle 4 years ago
parent
commit
096360a2b4
1 changed files with 6 additions and 4 deletions
  1. 6 4
      pollution.ipynb

+ 6 - 4
pollution.ipynb

@@ -50,6 +50,8 @@
     "        pollutant_releases['Lat'],\n",
     "    ),\n",
     ")\n",
+    "for column_name in pollutant_releases_geo.select_dtypes('object'):\n",
+    "    pollutant_releases_geo[column_name] = pollutant_releases_geo[column_name].astype('category')\n",
     "pollutant_releases_geo.head()"
    ]
   },
@@ -69,13 +71,13 @@
       "Lat                   652351 non-null float64\n",
       "Long                  652351 non-null float64\n",
       "ReportingYear         652351 non-null int64\n",
-      "PollutantName         652351 non-null object\n",
-      "PollutantGroupName    652351 non-null object\n",
+      "PollutantName         652351 non-null category\n",
+      "PollutantGroupName    652351 non-null category\n",
       "TotalQuantity         652351 non-null float64\n",
       "TotalQuantity         652351 non-null float64\n",
       "geometry              652351 non-null geometry\n",
-      "dtypes: float64(4), geometry(1), int64(2), object(2)\n",
-      "memory usage: 44.8+ MB\n"
+      "dtypes: category(2), float64(4), geometry(1), int64(2)\n",
+      "memory usage: 36.1 MB\n"
      ]
     }
    ],