{ "cells": [ { "cell_type": "markdown", "id": "ba251f66", "metadata": { "papermill": { "duration": 0.011825, "end_time": "2021-12-14T18:23:27.026491", "exception": false, "start_time": "2021-12-14T18:23:27.014666", "status": "completed" }, "tags": [] }, "source": [ "In this notebook, we're going to work with dates.\n", "\n", "Let's get started!" ] }, { "cell_type": "markdown", "id": "b174b798", "metadata": { "papermill": { "duration": 0.009886, "end_time": "2021-12-14T18:23:27.046876", "exception": false, "start_time": "2021-12-14T18:23:27.036990", "status": "completed" }, "tags": [] }, "source": [ "# Get our environment set up\n", "\n", "The first thing we'll need to do is load in the libraries and dataset we'll be using. We'll be working with a dataset that contains information on landslides that occured between 2007 and 2016. In the [**following exercise**](https://www.kaggle.com/kernels/fork/10824403), you'll apply your new skills to a dataset of worldwide earthquakes." ] }, { "cell_type": "code", "execution_count": 1, "id": "e77eb61e", "metadata": { "execution": { "iopub.execute_input": "2021-12-14T18:23:27.072817Z", "iopub.status.busy": "2021-12-14T18:23:27.071220Z", "iopub.status.idle": "2021-12-14T18:23:28.096759Z", "shell.execute_reply": "2021-12-14T18:23:28.096113Z" }, "papermill": { "duration": 1.039951, "end_time": "2021-12-14T18:23:28.096920", "exception": false, "start_time": "2021-12-14T18:23:27.056969", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "# modules we'll use\n", "import pandas as pd\n", "import numpy as np\n", "import seaborn as sns\n", "import datetime\n", "\n", "# read in our data\n", "landslides = pd.read_csv(\"../input/landslide-events/catalog.csv\")\n", "\n", "# set seed for reproducibility\n", "np.random.seed(0)" ] }, { "cell_type": "markdown", "id": "c2c6d76e", "metadata": { "papermill": { "duration": 0.010572, "end_time": "2021-12-14T18:23:28.117984", "exception": false, "start_time": "2021-12-14T18:23:28.107412", "status": "completed" }, "tags": [] }, "source": [ "Now we're ready to look at some dates!" ] }, { "cell_type": "markdown", "id": "79463dfa", "metadata": { "papermill": { "duration": 0.010058, "end_time": "2021-12-14T18:23:28.138449", "exception": false, "start_time": "2021-12-14T18:23:28.128391", "status": "completed" }, "tags": [] }, "source": [ "# Check the data type of our date column\n", "\n", "We begin by taking a look at the first five rows of the data." ] }, { "cell_type": "code", "execution_count": 2, "id": "5f70f1ea", "metadata": { "execution": { "iopub.execute_input": "2021-12-14T18:23:28.161611Z", "iopub.status.busy": "2021-12-14T18:23:28.161074Z", "iopub.status.idle": "2021-12-14T18:23:28.192867Z", "shell.execute_reply": "2021-12-14T18:23:28.193320Z" }, "papermill": { "duration": 0.044865, "end_time": "2021-12-14T18:23:28.193493", "exception": false, "start_time": "2021-12-14T18:23:28.148628", "status": "completed" }, "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", "
iddatetimecontinent_codecountry_namecountry_codestate/provincepopulationcity/towndistance...geolocationhazard_typelandslide_typelandslide_sizetriggerstorm_nameinjuriesfatalitiessource_namesource_link
0343/2/07NightNaNUnited StatesUSVirginia16000Cherry Hill3.40765...(38.600900000000003, -77.268199999999993)LandslideLandslideSmallRainNaNNaNNaNNBC 4 newshttp://www.nbc4.com/news/11186871/detail.html
1423/22/07NaNNaNUnited StatesUSOhio17288New Philadelphia3.33522...(40.517499999999998, -81.430499999999995)LandslideLandslideSmallRainNaNNaNNaNCanton Rep.comhttp://www.cantonrep.com/index.php?ID=345054&C...
2564/6/07NaNNaNUnited StatesUSPennsylvania15930Wilkinsburg2.91977...(40.4377, -79.915999999999997)LandslideLandslideSmallRainNaNNaNNaNThe Pittsburgh Channel.comhttps://web.archive.org/web/20080423132842/htt...
3594/14/07NaNNaNCanadaCAQuebec42786Châteauguay2.98682...(45.322600000000001, -73.777100000000004)LandslideRiverbank collapseSmallRainNaNNaNNaNLe Soleilhttp://www.hebdos.net/lsc/edition162007/articl...
4614/15/07NaNNaNUnited StatesUSKentucky6903Pikeville5.66542...(37.432499999999997, -82.493099999999998)LandslideLandslideSmallDownpourNaNNaN0.0Matthew Crawford (KGS)NaN
\n", "

5 rows × 23 columns

\n", "
" ], "text/plain": [ " id date time continent_code country_name country_code \\\n", "0 34 3/2/07 Night NaN United States US \n", "1 42 3/22/07 NaN NaN United States US \n", "2 56 4/6/07 NaN NaN United States US \n", "3 59 4/14/07 NaN NaN Canada CA \n", "4 61 4/15/07 NaN NaN United States US \n", "\n", " state/province population city/town distance ... \\\n", "0 Virginia 16000 Cherry Hill 3.40765 ... \n", "1 Ohio 17288 New Philadelphia 3.33522 ... \n", "2 Pennsylvania 15930 Wilkinsburg 2.91977 ... \n", "3 Quebec 42786 Châteauguay 2.98682 ... \n", "4 Kentucky 6903 Pikeville 5.66542 ... \n", "\n", " geolocation hazard_type landslide_type \\\n", "0 (38.600900000000003, -77.268199999999993) Landslide Landslide \n", "1 (40.517499999999998, -81.430499999999995) Landslide Landslide \n", "2 (40.4377, -79.915999999999997) Landslide Landslide \n", "3 (45.322600000000001, -73.777100000000004) Landslide Riverbank collapse \n", "4 (37.432499999999997, -82.493099999999998) Landslide Landslide \n", "\n", " landslide_size trigger storm_name injuries fatalities \\\n", "0 Small Rain NaN NaN NaN \n", "1 Small Rain NaN NaN NaN \n", "2 Small Rain NaN NaN NaN \n", "3 Small Rain NaN NaN NaN \n", "4 Small Downpour NaN NaN 0.0 \n", "\n", " source_name \\\n", "0 NBC 4 news \n", "1 Canton Rep.com \n", "2 The Pittsburgh Channel.com \n", "3 Le Soleil \n", "4 Matthew Crawford (KGS) \n", "\n", " source_link \n", "0 http://www.nbc4.com/news/11186871/detail.html \n", "1 http://www.cantonrep.com/index.php?ID=345054&C... \n", "2 https://web.archive.org/web/20080423132842/htt... \n", "3 http://www.hebdos.net/lsc/edition162007/articl... \n", "4 NaN \n", "\n", "[5 rows x 23 columns]" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "landslides.head()" ] }, { "cell_type": "markdown", "id": "8b125c71", "metadata": { "papermill": { "duration": 0.01081, "end_time": "2021-12-14T18:23:28.215621", "exception": false, "start_time": "2021-12-14T18:23:28.204811", "status": "completed" }, "tags": [] }, "source": [ "We'll be working with the \"date\" column from the `landslides` dataframe. Let's make sure it actually looks like it contains dates." ] }, { "cell_type": "code", "execution_count": 3, "id": "a1fb2ece", "metadata": { "execution": { "iopub.execute_input": "2021-12-14T18:23:28.241344Z", "iopub.status.busy": "2021-12-14T18:23:28.240732Z", "iopub.status.idle": "2021-12-14T18:23:28.248869Z", "shell.execute_reply": "2021-12-14T18:23:28.249294Z" }, "papermill": { "duration": 0.02292, "end_time": "2021-12-14T18:23:28.249461", "exception": false, "start_time": "2021-12-14T18:23:28.226541", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0 3/2/07\n", "1 3/22/07\n", "2 4/6/07\n", "3 4/14/07\n", "4 4/15/07\n", "Name: date, dtype: object\n" ] } ], "source": [ "# print the first few rows of the date column\n", "print(landslides['date'].head())" ] }, { "cell_type": "markdown", "id": "3f901759", "metadata": { "papermill": { "duration": 0.01164, "end_time": "2021-12-14T18:23:28.272900", "exception": false, "start_time": "2021-12-14T18:23:28.261260", "status": "completed" }, "tags": [] }, "source": [ "Yep, those are dates! But just because I, a human, can tell that these are dates doesn't mean that Python knows that they're dates. Notice that at the bottom of the output of `head()`, you can see that it says that the data type of this column is \"object\". \n", "\n", "> Pandas uses the \"object\" dtype for storing various types of data types, but most often when you see a column with the dtype \"object\" it will have strings in it. \n", "\n", "If you check the pandas dtype documentation [here](http://pandas.pydata.org/pandas-docs/stable/basics.html#dtypes), you'll notice that there's also a specific `datetime64` dtypes. Because the dtype of our column is `object` rather than `datetime64`, we can tell that Python doesn't know that this column contains dates.\n", "\n", "We can also look at just the dtype of a column without printing the first few rows:" ] }, { "cell_type": "code", "execution_count": 4, "id": "43138dd5", "metadata": { "execution": { "iopub.execute_input": "2021-12-14T18:23:28.301199Z", "iopub.status.busy": "2021-12-14T18:23:28.300554Z", "iopub.status.idle": "2021-12-14T18:23:28.302901Z", "shell.execute_reply": "2021-12-14T18:23:28.303328Z" }, "papermill": { "duration": 0.018653, "end_time": "2021-12-14T18:23:28.303494", "exception": false, "start_time": "2021-12-14T18:23:28.284841", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "dtype('O')" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# check the data type of our date column\n", "landslides['date'].dtype" ] }, { "cell_type": "markdown", "id": "7f9c49ee", "metadata": { "papermill": { "duration": 0.011298, "end_time": "2021-12-14T18:23:28.326309", "exception": false, "start_time": "2021-12-14T18:23:28.315011", "status": "completed" }, "tags": [] }, "source": [ "You may have to check the [numpy documentation](https://docs.scipy.org/doc/numpy-1.12.0/reference/generated/numpy.dtype.kind.html#numpy.dtype.kind) to match the letter code to the dtype of the object. \"O\" is the code for \"object\", so we can see that these two methods give us the same information." ] }, { "cell_type": "markdown", "id": "641e3c3b", "metadata": { "papermill": { "duration": 0.011354, "end_time": "2021-12-14T18:23:28.349169", "exception": false, "start_time": "2021-12-14T18:23:28.337815", "status": "completed" }, "tags": [] }, "source": [ "# Convert our date columns to datetime\n", "\n", "Now that we know that our date column isn't being recognized as a date, it's time to convert it so that it *is* recognized as a date. This is called \"parsing dates\" because we're taking in a string and identifying its component parts.\n", "\n", "We can determine what the format of our dates are with a guide called [\"strftime directive\", which you can find more information on at this link](http://strftime.org/). The basic idea is that you need to point out which parts of the date are where and what punctuation is between them. There are [lots of possible parts of a date](http://strftime.org/), but the most common are `%d` for day, `%m` for month, `%y` for a two-digit year and `%Y` for a four digit year.\n", "\n", "Some examples:\n", "\n", " * 1/17/07 has the format \"%m/%d/%y\"\n", " * 17-1-2007 has the format \"%d-%m-%Y\"\n", " \n", "Looking back up at the head of the \"date\" column in the landslides dataset, we can see that it's in the format \"month/day/two-digit year\", so we can use the same syntax as the first example to parse in our dates: " ] }, { "cell_type": "code", "execution_count": 5, "id": "9496181b", "metadata": { "execution": { "iopub.execute_input": "2021-12-14T18:23:28.375484Z", "iopub.status.busy": "2021-12-14T18:23:28.374813Z", "iopub.status.idle": "2021-12-14T18:23:28.385928Z", "shell.execute_reply": "2021-12-14T18:23:28.386453Z" }, "papermill": { "duration": 0.025978, "end_time": "2021-12-14T18:23:28.386629", "exception": false, "start_time": "2021-12-14T18:23:28.360651", "status": "completed" }, "scrolled": false, "tags": [] }, "outputs": [], "source": [ "# create a new column, date_parsed, with the parsed dates\n", "landslides['date_parsed'] = pd.to_datetime(landslides['date'], format=\"%m/%d/%y\")" ] }, { "cell_type": "markdown", "id": "ee0d1dfe", "metadata": { "papermill": { "duration": 0.011971, "end_time": "2021-12-14T18:23:28.410601", "exception": false, "start_time": "2021-12-14T18:23:28.398630", "status": "completed" }, "tags": [] }, "source": [ "Now when I check the first few rows of the new column, I can see that the dtype is `datetime64`. I can also see that my dates have been slightly rearranged so that they fit the default order datetime objects (year-month-day)." ] }, { "cell_type": "code", "execution_count": 6, "id": "9ec556f4", "metadata": { "execution": { "iopub.execute_input": "2021-12-14T18:23:28.437224Z", "iopub.status.busy": "2021-12-14T18:23:28.436647Z", "iopub.status.idle": "2021-12-14T18:23:28.442115Z", "shell.execute_reply": "2021-12-14T18:23:28.442597Z" }, "papermill": { "duration": 0.020269, "end_time": "2021-12-14T18:23:28.442764", "exception": false, "start_time": "2021-12-14T18:23:28.422495", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "0 2007-03-02\n", "1 2007-03-22\n", "2 2007-04-06\n", "3 2007-04-14\n", "4 2007-04-15\n", "Name: date_parsed, dtype: datetime64[ns]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# print the first few rows\n", "landslides['date_parsed'].head()" ] }, { "cell_type": "markdown", "id": "196ea595", "metadata": { "papermill": { "duration": 0.011772, "end_time": "2021-12-14T18:23:28.466691", "exception": false, "start_time": "2021-12-14T18:23:28.454919", "status": "completed" }, "tags": [] }, "source": [ "Now that our dates are parsed correctly, we can interact with them in useful ways.\n", "\n", "___\n", "* **What if I run into an error with multiple date formats?** While we're specifying the date format here, sometimes you'll run into an error when there are multiple date formats in a single column. If that happens, you can have pandas try to infer what the right date format should be. You can do that like so:\n", "\n", "`landslides['date_parsed'] = pd.to_datetime(landslides['Date'], infer_datetime_format=True)`\n", "\n", "* **Why don't you always use `infer_datetime_format = True?`** There are two big reasons not to always have pandas guess the time format. The first is that pandas won't always been able to figure out the correct date format, especially if someone has gotten creative with data entry. The second is that it's much slower than specifying the exact format of the dates." ] }, { "cell_type": "markdown", "id": "04985566", "metadata": { "papermill": { "duration": 0.011758, "end_time": "2021-12-14T18:23:28.490562", "exception": false, "start_time": "2021-12-14T18:23:28.478804", "status": "completed" }, "tags": [] }, "source": [ "# Select the day of the month\n", "\n", "Now that we have a column of parsed dates, we can extract information like the day of the month that a landslide occurred." ] }, { "cell_type": "code", "execution_count": 7, "id": "ae8e9316", "metadata": { "execution": { "iopub.execute_input": "2021-12-14T18:23:28.517959Z", "iopub.status.busy": "2021-12-14T18:23:28.517409Z", "iopub.status.idle": "2021-12-14T18:23:28.524344Z", "shell.execute_reply": "2021-12-14T18:23:28.523824Z" }, "papermill": { "duration": 0.021694, "end_time": "2021-12-14T18:23:28.524480", "exception": false, "start_time": "2021-12-14T18:23:28.502786", "status": "completed" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "0 2.0\n", "1 22.0\n", "2 6.0\n", "3 14.0\n", "4 15.0\n", "Name: date_parsed, dtype: float64" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# get the day of the month from the date_parsed column\n", "day_of_month_landslides = landslides['date_parsed'].dt.day\n", "day_of_month_landslides.head()" ] }, { "cell_type": "markdown", "id": "ffde1895", "metadata": { "papermill": { "duration": 0.012128, "end_time": "2021-12-14T18:23:28.549257", "exception": false, "start_time": "2021-12-14T18:23:28.537129", "status": "completed" }, "tags": [] }, "source": [ "If we tried to get the same information from the original \"date\" column, we would get an error: `AttributeError: Can only use .dt accessor with datetimelike values`. This is because `dt.day` doesn't know how to deal with a column with the dtype \"object\". Even though our dataframe has dates in it, we have to parse them before we can interact with them in a useful way." ] }, { "cell_type": "markdown", "id": "078d42c0", "metadata": { "papermill": { "duration": 0.011862, "end_time": "2021-12-14T18:23:28.573591", "exception": false, "start_time": "2021-12-14T18:23:28.561729", "status": "completed" }, "tags": [] }, "source": [ "# Plot the day of the month to check the date parsing\n", "\n", "One of the biggest dangers in parsing dates is mixing up the months and days. The `to_datetime()` function does have very helpful error messages, but it doesn't hurt to double-check that the days of the month we've extracted make sense. \n", "\n", "To do this, let's plot a histogram of the days of the month. We expect it to have values between 1 and 31 and, since there's no reason to suppose the landslides are more common on some days of the month than others, a relatively even distribution. (With a dip on 31 because not all months have 31 days.) Let's see if that's the case:" ] }, { "cell_type": "code", "execution_count": 8, "id": "53665da1", "metadata": { "execution": { "iopub.execute_input": "2021-12-14T18:23:28.601431Z", "iopub.status.busy": "2021-12-14T18:23:28.600514Z", "iopub.status.idle": "2021-12-14T18:23:28.882377Z", "shell.execute_reply": "2021-12-14T18:23:28.882830Z" }, "papermill": { "duration": 0.297338, "end_time": "2021-12-14T18:23:28.882986", "exception": false, "start_time": "2021-12-14T18:23:28.585648", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/opt/conda/lib/python3.7/site-packages/seaborn/distributions.py:2619: FutureWarning: `distplot` is a deprecated function and will be removed in a future version. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `histplot` (an axes-level function for histograms).\n", " warnings.warn(msg, FutureWarning)\n" ] }, { "data": { "text/plain": [ "" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAEHCAYAAAC3Ph1GAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8/fFQqAAAACXBIWXMAAAsTAAALEwEAmpwYAAAS8UlEQVR4nO3df4xlZ33f8ffHv2psSNaG6Wpjs12HOCDHLQ6MTAwUURtHhKZ4oxoHh0ZLZHVbiVAITWuHqCKJXMk0PwhSKGgTU29bwHaM3bWIAlgbp0Bbrdn1D/wLsDG249V6dwmxsKFJZPLtH/dZPB3P7JyZuXdmntn3S7q65+fc75ljf/aZ557znFQVkqT+HLfaBUiSlsYAl6ROGeCS1CkDXJI6ZYBLUqdOWMkPe8lLXlJbtmxZyY+UpO7t27fvW1U1NXv5igb4li1b2Lt370p+pCR1L8ljcy23C0WSOmWAS1KnDHBJ6pQBLkmdMsAlqVMGuCR1alCAJ/mVJPcnuS/Jp5KcnOSsJHuSPJzkhiQnTbpYSdJzFgzwJGcA/waYrqpzgeOBtwMfBD5UVT8G/BVwxSQLlST9/4Z2oZwAvCDJCcApwAHgQuCmtn4nsHXs1UmS5rXgnZhVtT/J7wCPA/8X+DywD3iqqp5tmz0BnDHX/km2A9sBNm/ePI6a1YFP7nl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bmqt+cfALVX1PYDW2gU4N8nVwAbghcDnZu/Yhix9LfDHozGUAPh7C3zejTUaEe+hJI8wGh70m8AfJDkP+D7w4zO2v6Oqvtmm7wV+N8kHgc9U1ReTnAucC9zWajgeONAGQdpQo4dOAPw3RsMPS0tmgKsX1wFbq+qeJO9k1Bqe7ThGg+uft4ifO3swoAJ+hdFgWK9sP/OvZ6z/7g82rPp6klcBbwGuTrKb0cBm91fVBTN/6JFR7KRxsg9ca80XgK1JXtCG6f1nbfmLGLVkTwTeMWP7p9s6avSggG8meRuMhjJN8soFPu9tSY5L8jLgR4GvMeoKOdBa5r/IqBX9PEl+BPheVf13Rl0ir2r7TyW5oG1zYpKfqNH40U+10fmYdQzSkhjgWlNq9PzEG4B7gD9lNHY8wH9gNJzq/wK+OmOX64F/l+SuFsLvAK5oXxTez8LPWn0cuKN91r+uqr8G/jOwrf2MVzCj1T3LPwTuaI/Y+gBwdY2e8Xop8MG2/92MunUAfgn4SNs+z/tp0iI5nKyOWUmuY9R3fdNC20prkS1wSeqUX2Jq3Uvy68DbZi3+46p65yqUI42NXSiS1Cm7UCSpUwa4JHXKAJekThngktSp/wf6oidBFKn33AAAAABJRU5ErkJggg==\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "# remove na's\n", "day_of_month_landslides = day_of_month_landslides.dropna()\n", "\n", "# plot the day of the month\n", "sns.distplot(day_of_month_landslides, kde=False, bins=31)" ] }, { "cell_type": "markdown", "id": "53c32600", "metadata": { "papermill": { "duration": 0.013285, "end_time": "2021-12-14T18:23:28.910234", "exception": false, "start_time": "2021-12-14T18:23:28.896949", "status": "completed" }, "tags": [] }, "source": [ "Yep, it looks like we did parse our dates correctly & this graph makes good sense to me.\n", "\n", "# Your turn\n", "\n", "Write code to [**parse the dates**](https://www.kaggle.com/kernels/fork/10824403) in a dataset of worldwide earthquakes." ] }, { "cell_type": "markdown", "id": "39293a02", "metadata": { "papermill": { "duration": 0.013108, "end_time": "2021-12-14T18:23:28.936775", "exception": false, "start_time": "2021-12-14T18:23:28.923667", "status": "completed" }, "tags": [] }, "source": [ "---\n", "\n", "\n", "\n", "\n", "*Have questions or comments? Visit the [course discussion forum](https://www.kaggle.com/learn/data-cleaning/discussion) to chat with other learners.*" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.12" }, "papermill": { "default_parameters": {}, "duration": 11.210793, "end_time": "2021-12-14T18:23:29.662548", "environment_variables": {}, "exception": null, "input_path": "__notebook__.ipynb", "output_path": "__notebook__.ipynb", "parameters": {}, "start_time": "2021-12-14T18:23:18.451755", "version": "2.3.3" } }, "nbformat": 4, "nbformat_minor": 5 }