Skip to content

Instantly share code, notes, and snippets.

@taruma
Last active April 14, 2024 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taruma/cad07f29ffc025ba9e7801e752be3444 to your computer and use it in GitHub Desktop.
Save taruma/cad07f29ffc025ba9e7801e752be3444 to your computer and use it in GitHub Desktop.
taruma_hk84_tabel_ringkasan_jamjaman.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "taruma_hk84_tabel_ringkasan_jamjaman.ipynb",
"provenance": [],
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/taruma/cad07f29ffc025ba9e7801e752be3444/taruma_hk84_tabel_ringkasan_jamjaman.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "PijWaYlBOu6E"
},
"source": [
"Berdasarkan isu [#84](https://github.com/taruma/hidrokit/issues/84): **request: buat ringkasan tabel jam-jaman dengan durasinya**\n",
"\n",
"Referensi isu:\n",
"- `hidrokit.contrib.taruma.hk79` [#79](https://github.com/taruma/hidrokit/issues/79). \\([lihat notebook / manual](https://nbviewer.jupyter.org/gist/taruma/05dab67fac8313a94134ac02d0398897)\\). **request: ambil dataset hujan jam-jaman dari excel**\n",
"- `hidrokit.contrib.taruma.hk73` [#73](https://github.com/taruma/hidrokit/issues/73). \\([lihat notebook / manual](https://nbviewer.jupyter.org/gist/taruma/b00880905f297013f046dad95dc2e284)\\). **request: mengolah berkas dari data bmkg**\n",
"\n",
"Deskripsi Permasalahan:\n",
"- Setelah memperoleh dataset menggunakan `.hk79`, maka data jam-jaman akan diproses lebih lanjut lagi.\n",
"- Dalam isu ini, akan dibuat tabel ringkasan mengenai hujan jam-jaman beserta durasinya.\n",
"- Tabel ringkasan dapat disimpan dalam berbagai format (excel atau csv) dengan menggunakan `pandas`.\n",
"\n",
"Strategi Penyelesaian:\n",
"- Ditentukan/diasumsikan bahwa observasi hanya dilakukan per-24 jam, maka durasi terlama dalam tabel sebesar 24 jam.\n",
"- Mempersiapkan DF (`DataFrame`) yang akan digunakan dan menentukan kolom mana yang akan dibuat ringkasannya.\n",
"- Ambil sub-DF dari DF setiap 24 jam, kemudian diambil informasi kejadian hujan jam-jaman.\n",
" - Membuat `index_grouped` yang merupakan `list of list` index kejadian hujan yang berturut-turut. Fungsi ini telah dikembangkan pada modul `.hk73`.\n",
" - Membuat tiga `list` yang merupakan `list` untuk tanggal observasi, `list` untuk jam observasi, dan `list` untuk nilai hujan observasi.\n",
" - Mengubah tiga `list` tersebut ke dalam bentuk `dictionary`.\n",
"- Ulangi tahap sebelumnya untuk setiap hari (24 jam). Dan menggabungkan seluruh `dictionary` dalam satu peubah.\n",
"- Mengubah `dictionary` menjadi `pandas.DataFrame`.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "mxXIWs-iRvPM"
},
"source": [
"# PERSIAPAN DAN DATASET"
]
},
{
"cell_type": "code",
"metadata": {
"id": "zIWmJH0_Ociy",
"outputId": "c795dd86-2429-4a13-fea0-5a4afb194ba3",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"source": [
"try:\n",
" import hidrokit\n",
"except:\n",
" !pip install git+https://github.com/hidrokit/hidrokit.git@243-refactor-hk84\n",
"print(f'hidrokit version: {hidrokit.__version__}')"
],
"execution_count": 1,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"hidrokit version: 0.5.0\n"
]
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "lxLA_9I_R2ej"
},
"source": [
"!wget -O aurene_clean.csv \"https://taruma.github.io/assets/hidrokit_dataset/AURENE_STATION_clean.csv\" -q"
],
"execution_count": 2,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "uahcisYRSaFc"
},
"source": [
"import pandas as pd\n",
"import numpy as np"
],
"execution_count": 3,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "5IZgq0Lkgp0i",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "67446548-0998-4910-b4a5-92a508226266"
},
"source": [
"# Load Dataset\n",
"dataset = pd.read_csv('aurene_clean.csv', index_col=0, parse_dates=True)\n",
"dataset.info()"
],
"execution_count": 4,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"DatetimeIndex: 26304 entries, 2000-01-01 00:00:00 to 2002-12-31 23:00:00\n",
"Data columns (total 1 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 AURENE 2759 non-null float64\n",
"dtypes: float64(1)\n",
"memory usage: 411.0 KB\n"
]
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "D8bCLVRfSdjx"
},
"source": [
"# KODE"
]
},
{
"cell_type": "code",
"metadata": {
"id": "AbFHYIzwSc0U"
},
"source": [
"import pandas as pd\n",
"from hidrokit.contrib.taruma import hk73\n",
"\n",
"\n",
"def _time_grouped(df, index_grouped, col, date_fmt=\"%Y-%m-%d\", hour_fmt=\"%H:%M\"):\n",
" \"\"\"\n",
" Return index_grouped as (list of date, list of hour)\n",
"\n",
" Parameters:\n",
" - df: pandas DataFrame\n",
" The DataFrame containing the data.\n",
" - index_grouped: list of tuples\n",
" The index groups to be processed.\n",
" - col: int or str\n",
" The column index or name to extract the date and hour values from.\n",
" - date_fmt: str, optional\n",
" The format string for the date values. Default is '%Y-%m-%d'.\n",
" - hour_fmt: str, optional\n",
" The format string for the hour values. Default is '%H:%M'.\n",
"\n",
" Returns:\n",
" - date: list of lists\n",
" The list of date values for each index group.\n",
" - hour: list of lists\n",
" The list of hour values for each index group.\n",
" \"\"\"\n",
" date = []\n",
" hour = []\n",
" for item in index_grouped:\n",
" date_val = df.iloc[[item[0]], col].index.strftime(date_fmt).to_list()\n",
" hour_val = df.iloc[[item[0]], col].index.strftime(hour_fmt).to_list()\n",
" date.append(date_val)\n",
" hour.append(hour_val)\n",
" return date, hour\n",
"\n",
"\n",
"def _value_grouped(df, index_grouped, col):\n",
" \"\"\"Return index_grouped as a list of value lists.\n",
"\n",
" Args:\n",
" df (pandas.DataFrame): The input DataFrame.\n",
" index_grouped (list): The list of indices to group.\n",
" col (int): The column index to extract values from.\n",
"\n",
" Returns:\n",
" list: A list of value lists corresponding to the grouped indices.\n",
" \"\"\"\n",
" value = []\n",
" for item in index_grouped:\n",
" value_val = df.iloc[item, col].to_list()\n",
" value.append(value_val)\n",
" return value\n",
"\n",
"\n",
"def _dict_grouped(date_list, hour_list, value_list, start=0):\n",
" \"\"\"\n",
" Join three lists and return as a dictionary.\n",
"\n",
" Args:\n",
" date_list (list): List of dates.\n",
" hour_list (list): List of hours.\n",
" value_list (list): List of values.\n",
" start (int, optional): Starting index for the dictionary keys. Defaults to 0.\n",
"\n",
" Returns:\n",
" dict: Dictionary with keys as indices and values as concatenated date, hour, and value.\n",
"\n",
" \"\"\"\n",
" item_list = enumerate(zip(date_list, hour_list, value_list), start=start)\n",
" return {i: date + hour + value for i, (date, hour, value) in item_list}\n",
"\n",
"\n",
"def summary_hourly(\n",
" dataframe,\n",
" column,\n",
" n_hours=24,\n",
" text_date=None,\n",
" return_as_dataframe=True,\n",
" date_format=\"%Y-%m-%d\",\n",
" hour_format=\"%H:%M\",\n",
"): # pylint: disable=too-many-arguments,too-many-locals\n",
" \"\"\"\n",
" Generate a summary of hourly data from a DataFrame.\n",
"\n",
" Args:\n",
" df (pandas.DataFrame): The input DataFrame.\n",
" column (str): The name of the column containing the hourly data.\n",
" n_hours (int, optional): The number of hours to group together. Defaults to 24.\n",
" text_date (list, optional):\n",
" The list of column names to include in the summary. Defaults to ['date', 'hour'].\n",
" as_df (bool, optional): Whether to return the summary as a DataFrame. Defaults to True.\n",
" date_fmt (str, optional): The date format string. Defaults to '%Y-%m-%d'.\n",
" hour_fmt (str, optional): The hour format string. Defaults to '%H:%M'.\n",
"\n",
" Returns:\n",
" pandas.DataFrame or dict:\n",
" The summary of hourly data. If `as_df` is True, a DataFrame is returned.\n",
" Otherwise, a dictionary is returned.\n",
" \"\"\"\n",
" col = dataframe.columns.get_loc(column)\n",
" nrows, _ = dataframe.shape\n",
" results = {}\n",
" text_date = [\"date\", \"hour\"] if text_date is None else text_date\n",
"\n",
" for i in range(0, nrows, n_hours):\n",
" sub_df = dataframe.iloc[i : i + n_hours]\n",
" ix_array = hk73.get_missing_data_indices(~sub_df.iloc[:, col].isna().values)\n",
" ix_grouped = hk73.group_consecutive_elements(ix_array)\n",
" date, hour = _time_grouped(\n",
" sub_df, ix_grouped, col, date_fmt=date_format, hour_fmt=hour_format\n",
" )\n",
" value = _value_grouped(sub_df, ix_grouped, col)\n",
" each_hours = _dict_grouped(date, hour, value, start=i)\n",
" results.update(each_hours)\n",
"\n",
" if return_as_dataframe:\n",
" columns_name = text_date + [i for i in range(1, n_hours + 1)]\n",
" df_results = pd.DataFrame.from_dict(\n",
" results, orient=\"index\", columns=columns_name\n",
" )\n",
" return df_results\n",
" return results\n"
],
"execution_count": 6,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "hUCLu72zUHE1"
},
"source": [
"# PENERAPAN"
]
},
{
"cell_type": "code",
"metadata": {
"id": "g4nxkghGU7GM",
"outputId": "73c4403e-af16-4754-8ce7-cc7be55efd67",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 236
}
},
"source": [
"summary = summary_hourly(dataset, 'AURENE')\n",
"summary.head()"
],
"execution_count": 7,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" date hour 1 2 3 4 5 6 7 8 ... 15 16 17 18 \\\n",
"0 2000-01-01 08:00 0.3 NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN \n",
"24 2000-01-02 08:00 7.0 0.5 0.5 NaN NaN NaN NaN NaN ... NaN NaN NaN NaN \n",
"48 2000-01-03 00:00 0.6 NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN \n",
"49 2000-01-03 05:00 0.6 NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN \n",
"50 2000-01-03 09:00 2.2 NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN \n",
"\n",
" 19 20 21 22 23 24 \n",
"0 NaN NaN NaN NaN NaN NaN \n",
"24 NaN NaN NaN NaN NaN NaN \n",
"48 NaN NaN NaN NaN NaN NaN \n",
"49 NaN NaN NaN NaN NaN NaN \n",
"50 NaN NaN NaN NaN NaN NaN \n",
"\n",
"[5 rows x 26 columns]"
],
"text/html": [
"\n",
" <div id=\"df-a3cae008-fef8-4aa0-b46a-763fc7dde792\" class=\"colab-df-container\">\n",
" <div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>date</th>\n",
" <th>hour</th>\n",
" <th>1</th>\n",
" <th>2</th>\n",
" <th>3</th>\n",
" <th>4</th>\n",
" <th>5</th>\n",
" <th>6</th>\n",
" <th>7</th>\n",
" <th>8</th>\n",
" <th>...</th>\n",
" <th>15</th>\n",
" <th>16</th>\n",
" <th>17</th>\n",
" <th>18</th>\n",
" <th>19</th>\n",
" <th>20</th>\n",
" <th>21</th>\n",
" <th>22</th>\n",
" <th>23</th>\n",
" <th>24</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2000-01-01</td>\n",
" <td>08:00</td>\n",
" <td>0.3</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>24</th>\n",
" <td>2000-01-02</td>\n",
" <td>08:00</td>\n",
" <td>7.0</td>\n",
" <td>0.5</td>\n",
" <td>0.5</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>48</th>\n",
" <td>2000-01-03</td>\n",
" <td>00:00</td>\n",
" <td>0.6</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>49</th>\n",
" <td>2000-01-03</td>\n",
" <td>05:00</td>\n",
" <td>0.6</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>50</th>\n",
" <td>2000-01-03</td>\n",
" <td>09:00</td>\n",
" <td>2.2</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>5 rows × 26 columns</p>\n",
"</div>\n",
" <div class=\"colab-df-buttons\">\n",
"\n",
" <div class=\"colab-df-container\">\n",
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-a3cae008-fef8-4aa0-b46a-763fc7dde792')\"\n",
" title=\"Convert this dataframe to an interactive table.\"\n",
" style=\"display:none;\">\n",
"\n",
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
" <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
" </svg>\n",
" </button>\n",
"\n",
" <style>\n",
" .colab-df-container {\n",
" display:flex;\n",
" gap: 12px;\n",
" }\n",
"\n",
" .colab-df-convert {\n",
" background-color: #E8F0FE;\n",
" border: none;\n",
" border-radius: 50%;\n",
" cursor: pointer;\n",
" display: none;\n",
" fill: #1967D2;\n",
" height: 32px;\n",
" padding: 0 0 0 0;\n",
" width: 32px;\n",
" }\n",
"\n",
" .colab-df-convert:hover {\n",
" background-color: #E2EBFA;\n",
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
" fill: #174EA6;\n",
" }\n",
"\n",
" .colab-df-buttons div {\n",
" margin-bottom: 4px;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-convert {\n",
" background-color: #3B4455;\n",
" fill: #D2E3FC;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-convert:hover {\n",
" background-color: #434B5C;\n",
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
" fill: #FFFFFF;\n",
" }\n",
" </style>\n",
"\n",
" <script>\n",
" const buttonEl =\n",
" document.querySelector('#df-a3cae008-fef8-4aa0-b46a-763fc7dde792 button.colab-df-convert');\n",
" buttonEl.style.display =\n",
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
"\n",
" async function convertToInteractive(key) {\n",
" const element = document.querySelector('#df-a3cae008-fef8-4aa0-b46a-763fc7dde792');\n",
" const dataTable =\n",
" await google.colab.kernel.invokeFunction('convertToInteractive',\n",
" [key], {});\n",
" if (!dataTable) return;\n",
"\n",
" const docLinkHtml = 'Like what you see? Visit the ' +\n",
" '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
" + ' to learn more about interactive tables.';\n",
" element.innerHTML = '';\n",
" dataTable['output_type'] = 'display_data';\n",
" await google.colab.output.renderOutput(dataTable, element);\n",
" const docLink = document.createElement('div');\n",
" docLink.innerHTML = docLinkHtml;\n",
" element.appendChild(docLink);\n",
" }\n",
" </script>\n",
" </div>\n",
"\n",
"\n",
"<div id=\"df-c4888e44-dee6-4516-ad33-784dc88f4271\">\n",
" <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-c4888e44-dee6-4516-ad33-784dc88f4271')\"\n",
" title=\"Suggest charts\"\n",
" style=\"display:none;\">\n",
"\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
" width=\"24px\">\n",
" <g>\n",
" <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
" </g>\n",
"</svg>\n",
" </button>\n",
"\n",
"<style>\n",
" .colab-df-quickchart {\n",
" --bg-color: #E8F0FE;\n",
" --fill-color: #1967D2;\n",
" --hover-bg-color: #E2EBFA;\n",
" --hover-fill-color: #174EA6;\n",
" --disabled-fill-color: #AAA;\n",
" --disabled-bg-color: #DDD;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-quickchart {\n",
" --bg-color: #3B4455;\n",
" --fill-color: #D2E3FC;\n",
" --hover-bg-color: #434B5C;\n",
" --hover-fill-color: #FFFFFF;\n",
" --disabled-bg-color: #3B4455;\n",
" --disabled-fill-color: #666;\n",
" }\n",
"\n",
" .colab-df-quickchart {\n",
" background-color: var(--bg-color);\n",
" border: none;\n",
" border-radius: 50%;\n",
" cursor: pointer;\n",
" display: none;\n",
" fill: var(--fill-color);\n",
" height: 32px;\n",
" padding: 0;\n",
" width: 32px;\n",
" }\n",
"\n",
" .colab-df-quickchart:hover {\n",
" background-color: var(--hover-bg-color);\n",
" box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
" fill: var(--button-hover-fill-color);\n",
" }\n",
"\n",
" .colab-df-quickchart-complete:disabled,\n",
" .colab-df-quickchart-complete:disabled:hover {\n",
" background-color: var(--disabled-bg-color);\n",
" fill: var(--disabled-fill-color);\n",
" box-shadow: none;\n",
" }\n",
"\n",
" .colab-df-spinner {\n",
" border: 2px solid var(--fill-color);\n",
" border-color: transparent;\n",
" border-bottom-color: var(--fill-color);\n",
" animation:\n",
" spin 1s steps(1) infinite;\n",
" }\n",
"\n",
" @keyframes spin {\n",
" 0% {\n",
" border-color: transparent;\n",
" border-bottom-color: var(--fill-color);\n",
" border-left-color: var(--fill-color);\n",
" }\n",
" 20% {\n",
" border-color: transparent;\n",
" border-left-color: var(--fill-color);\n",
" border-top-color: var(--fill-color);\n",
" }\n",
" 30% {\n",
" border-color: transparent;\n",
" border-left-color: var(--fill-color);\n",
" border-top-color: var(--fill-color);\n",
" border-right-color: var(--fill-color);\n",
" }\n",
" 40% {\n",
" border-color: transparent;\n",
" border-right-color: var(--fill-color);\n",
" border-top-color: var(--fill-color);\n",
" }\n",
" 60% {\n",
" border-color: transparent;\n",
" border-right-color: var(--fill-color);\n",
" }\n",
" 80% {\n",
" border-color: transparent;\n",
" border-right-color: var(--fill-color);\n",
" border-bottom-color: var(--fill-color);\n",
" }\n",
" 90% {\n",
" border-color: transparent;\n",
" border-bottom-color: var(--fill-color);\n",
" }\n",
" }\n",
"</style>\n",
"\n",
" <script>\n",
" async function quickchart(key) {\n",
" const quickchartButtonEl =\n",
" document.querySelector('#' + key + ' button');\n",
" quickchartButtonEl.disabled = true; // To prevent multiple clicks.\n",
" quickchartButtonEl.classList.add('colab-df-spinner');\n",
" try {\n",
" const charts = await google.colab.kernel.invokeFunction(\n",
" 'suggestCharts', [key], {});\n",
" } catch (error) {\n",
" console.error('Error during call to suggestCharts:', error);\n",
" }\n",
" quickchartButtonEl.classList.remove('colab-df-spinner');\n",
" quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
" }\n",
" (() => {\n",
" let quickchartButtonEl =\n",
" document.querySelector('#df-c4888e44-dee6-4516-ad33-784dc88f4271 button');\n",
" quickchartButtonEl.style.display =\n",
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
" })();\n",
" </script>\n",
"</div>\n",
" </div>\n",
" </div>\n"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "dataframe",
"variable_name": "summary"
}
},
"metadata": {},
"execution_count": 7
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "cGdS4rZklC8s",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 549
},
"outputId": "2a4b479b-3ff3-4e93-fb58-a664063d0674"
},
"source": [
"summary.sample(n=15)"
],
"execution_count": 8,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" date hour 1 2 3 4 5 6 7 8 ... 15 16 17 \\\n",
"25944 2002-12-17 06:00 3.2 NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN \n",
"21792 2002-06-27 10:00 0.5 NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN \n",
"25417 2002-11-25 14:00 0.5 0.2 NaN NaN NaN NaN NaN NaN ... NaN NaN NaN \n",
"14785 2001-09-08 07:00 1.0 NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN \n",
"18433 2002-02-07 07:00 2.4 NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN \n",
"9049 2001-01-12 17:00 0.5 0.8 NaN NaN NaN NaN NaN NaN ... NaN NaN NaN \n",
"18144 2002-01-26 05:00 0.2 NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN \n",
"15217 2001-09-26 11:00 3.3 0.7 0.1 NaN NaN NaN NaN NaN ... NaN NaN NaN \n",
"5376 2000-08-12 12:00 0.5 0.5 NaN NaN NaN NaN NaN NaN ... NaN NaN NaN \n",
"15433 2001-10-05 20:00 0.1 NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN \n",
"16106 2001-11-02 14:00 0.2 NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN \n",
"11952 2001-05-13 07:00 1.0 NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN \n",
"11234 2001-04-13 09:00 0.2 0.1 NaN NaN NaN NaN NaN NaN ... NaN NaN NaN \n",
"18266 2002-01-31 13:00 5.8 0.2 0.3 NaN NaN NaN NaN NaN ... NaN NaN NaN \n",
"50 2000-01-03 09:00 2.2 NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN \n",
"\n",
" 18 19 20 21 22 23 24 \n",
"25944 NaN NaN NaN NaN NaN NaN NaN \n",
"21792 NaN NaN NaN NaN NaN NaN NaN \n",
"25417 NaN NaN NaN NaN NaN NaN NaN \n",
"14785 NaN NaN NaN NaN NaN NaN NaN \n",
"18433 NaN NaN NaN NaN NaN NaN NaN \n",
"9049 NaN NaN NaN NaN NaN NaN NaN \n",
"18144 NaN NaN NaN NaN NaN NaN NaN \n",
"15217 NaN NaN NaN NaN NaN NaN NaN \n",
"5376 NaN NaN NaN NaN NaN NaN NaN \n",
"15433 NaN NaN NaN NaN NaN NaN NaN \n",
"16106 NaN NaN NaN NaN NaN NaN NaN \n",
"11952 NaN NaN NaN NaN NaN NaN NaN \n",
"11234 NaN NaN NaN NaN NaN NaN NaN \n",
"18266 NaN NaN NaN NaN NaN NaN NaN \n",
"50 NaN NaN NaN NaN NaN NaN NaN \n",
"\n",
"[15 rows x 26 columns]"
],
"text/html": [
"\n",
" <div id=\"df-3b96b974-9b24-49cd-8aff-4799dcc2b1b1\" class=\"colab-df-container\">\n",
" <div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>date</th>\n",
" <th>hour</th>\n",
" <th>1</th>\n",
" <th>2</th>\n",
" <th>3</th>\n",
" <th>4</th>\n",
" <th>5</th>\n",
" <th>6</th>\n",
" <th>7</th>\n",
" <th>8</th>\n",
" <th>...</th>\n",
" <th>15</th>\n",
" <th>16</th>\n",
" <th>17</th>\n",
" <th>18</th>\n",
" <th>19</th>\n",
" <th>20</th>\n",
" <th>21</th>\n",
" <th>22</th>\n",
" <th>23</th>\n",
" <th>24</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>25944</th>\n",
" <td>2002-12-17</td>\n",
" <td>06:00</td>\n",
" <td>3.2</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21792</th>\n",
" <td>2002-06-27</td>\n",
" <td>10:00</td>\n",
" <td>0.5</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25417</th>\n",
" <td>2002-11-25</td>\n",
" <td>14:00</td>\n",
" <td>0.5</td>\n",
" <td>0.2</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14785</th>\n",
" <td>2001-09-08</td>\n",
" <td>07:00</td>\n",
" <td>1.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18433</th>\n",
" <td>2002-02-07</td>\n",
" <td>07:00</td>\n",
" <td>2.4</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9049</th>\n",
" <td>2001-01-12</td>\n",
" <td>17:00</td>\n",
" <td>0.5</td>\n",
" <td>0.8</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18144</th>\n",
" <td>2002-01-26</td>\n",
" <td>05:00</td>\n",
" <td>0.2</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15217</th>\n",
" <td>2001-09-26</td>\n",
" <td>11:00</td>\n",
" <td>3.3</td>\n",
" <td>0.7</td>\n",
" <td>0.1</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5376</th>\n",
" <td>2000-08-12</td>\n",
" <td>12:00</td>\n",
" <td>0.5</td>\n",
" <td>0.5</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15433</th>\n",
" <td>2001-10-05</td>\n",
" <td>20:00</td>\n",
" <td>0.1</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16106</th>\n",
" <td>2001-11-02</td>\n",
" <td>14:00</td>\n",
" <td>0.2</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11952</th>\n",
" <td>2001-05-13</td>\n",
" <td>07:00</td>\n",
" <td>1.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11234</th>\n",
" <td>2001-04-13</td>\n",
" <td>09:00</td>\n",
" <td>0.2</td>\n",
" <td>0.1</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18266</th>\n",
" <td>2002-01-31</td>\n",
" <td>13:00</td>\n",
" <td>5.8</td>\n",
" <td>0.2</td>\n",
" <td>0.3</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>50</th>\n",
" <td>2000-01-03</td>\n",
" <td>09:00</td>\n",
" <td>2.2</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>15 rows × 26 columns</p>\n",
"</div>\n",
" <div class=\"colab-df-buttons\">\n",
"\n",
" <div class=\"colab-df-container\">\n",
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-3b96b974-9b24-49cd-8aff-4799dcc2b1b1')\"\n",
" title=\"Convert this dataframe to an interactive table.\"\n",
" style=\"display:none;\">\n",
"\n",
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
" <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
" </svg>\n",
" </button>\n",
"\n",
" <style>\n",
" .colab-df-container {\n",
" display:flex;\n",
" gap: 12px;\n",
" }\n",
"\n",
" .colab-df-convert {\n",
" background-color: #E8F0FE;\n",
" border: none;\n",
" border-radius: 50%;\n",
" cursor: pointer;\n",
" display: none;\n",
" fill: #1967D2;\n",
" height: 32px;\n",
" padding: 0 0 0 0;\n",
" width: 32px;\n",
" }\n",
"\n",
" .colab-df-convert:hover {\n",
" background-color: #E2EBFA;\n",
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
" fill: #174EA6;\n",
" }\n",
"\n",
" .colab-df-buttons div {\n",
" margin-bottom: 4px;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-convert {\n",
" background-color: #3B4455;\n",
" fill: #D2E3FC;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-convert:hover {\n",
" background-color: #434B5C;\n",
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
" fill: #FFFFFF;\n",
" }\n",
" </style>\n",
"\n",
" <script>\n",
" const buttonEl =\n",
" document.querySelector('#df-3b96b974-9b24-49cd-8aff-4799dcc2b1b1 button.colab-df-convert');\n",
" buttonEl.style.display =\n",
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
"\n",
" async function convertToInteractive(key) {\n",
" const element = document.querySelector('#df-3b96b974-9b24-49cd-8aff-4799dcc2b1b1');\n",
" const dataTable =\n",
" await google.colab.kernel.invokeFunction('convertToInteractive',\n",
" [key], {});\n",
" if (!dataTable) return;\n",
"\n",
" const docLinkHtml = 'Like what you see? Visit the ' +\n",
" '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
" + ' to learn more about interactive tables.';\n",
" element.innerHTML = '';\n",
" dataTable['output_type'] = 'display_data';\n",
" await google.colab.output.renderOutput(dataTable, element);\n",
" const docLink = document.createElement('div');\n",
" docLink.innerHTML = docLinkHtml;\n",
" element.appendChild(docLink);\n",
" }\n",
" </script>\n",
" </div>\n",
"\n",
"\n",
"<div id=\"df-d056786c-bbf1-4c9d-86ac-295a05c72465\">\n",
" <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-d056786c-bbf1-4c9d-86ac-295a05c72465')\"\n",
" title=\"Suggest charts\"\n",
" style=\"display:none;\">\n",
"\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
" width=\"24px\">\n",
" <g>\n",
" <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
" </g>\n",
"</svg>\n",
" </button>\n",
"\n",
"<style>\n",
" .colab-df-quickchart {\n",
" --bg-color: #E8F0FE;\n",
" --fill-color: #1967D2;\n",
" --hover-bg-color: #E2EBFA;\n",
" --hover-fill-color: #174EA6;\n",
" --disabled-fill-color: #AAA;\n",
" --disabled-bg-color: #DDD;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-quickchart {\n",
" --bg-color: #3B4455;\n",
" --fill-color: #D2E3FC;\n",
" --hover-bg-color: #434B5C;\n",
" --hover-fill-color: #FFFFFF;\n",
" --disabled-bg-color: #3B4455;\n",
" --disabled-fill-color: #666;\n",
" }\n",
"\n",
" .colab-df-quickchart {\n",
" background-color: var(--bg-color);\n",
" border: none;\n",
" border-radius: 50%;\n",
" cursor: pointer;\n",
" display: none;\n",
" fill: var(--fill-color);\n",
" height: 32px;\n",
" padding: 0;\n",
" width: 32px;\n",
" }\n",
"\n",
" .colab-df-quickchart:hover {\n",
" background-color: var(--hover-bg-color);\n",
" box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
" fill: var(--button-hover-fill-color);\n",
" }\n",
"\n",
" .colab-df-quickchart-complete:disabled,\n",
" .colab-df-quickchart-complete:disabled:hover {\n",
" background-color: var(--disabled-bg-color);\n",
" fill: var(--disabled-fill-color);\n",
" box-shadow: none;\n",
" }\n",
"\n",
" .colab-df-spinner {\n",
" border: 2px solid var(--fill-color);\n",
" border-color: transparent;\n",
" border-bottom-color: var(--fill-color);\n",
" animation:\n",
" spin 1s steps(1) infinite;\n",
" }\n",
"\n",
" @keyframes spin {\n",
" 0% {\n",
" border-color: transparent;\n",
" border-bottom-color: var(--fill-color);\n",
" border-left-color: var(--fill-color);\n",
" }\n",
" 20% {\n",
" border-color: transparent;\n",
" border-left-color: var(--fill-color);\n",
" border-top-color: var(--fill-color);\n",
" }\n",
" 30% {\n",
" border-color: transparent;\n",
" border-left-color: var(--fill-color);\n",
" border-top-color: var(--fill-color);\n",
" border-right-color: var(--fill-color);\n",
" }\n",
" 40% {\n",
" border-color: transparent;\n",
" border-right-color: var(--fill-color);\n",
" border-top-color: var(--fill-color);\n",
" }\n",
" 60% {\n",
" border-color: transparent;\n",
" border-right-color: var(--fill-color);\n",
" }\n",
" 80% {\n",
" border-color: transparent;\n",
" border-right-color: var(--fill-color);\n",
" border-bottom-color: var(--fill-color);\n",
" }\n",
" 90% {\n",
" border-color: transparent;\n",
" border-bottom-color: var(--fill-color);\n",
" }\n",
" }\n",
"</style>\n",
"\n",
" <script>\n",
" async function quickchart(key) {\n",
" const quickchartButtonEl =\n",
" document.querySelector('#' + key + ' button');\n",
" quickchartButtonEl.disabled = true; // To prevent multiple clicks.\n",
" quickchartButtonEl.classList.add('colab-df-spinner');\n",
" try {\n",
" const charts = await google.colab.kernel.invokeFunction(\n",
" 'suggestCharts', [key], {});\n",
" } catch (error) {\n",
" console.error('Error during call to suggestCharts:', error);\n",
" }\n",
" quickchartButtonEl.classList.remove('colab-df-spinner');\n",
" quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
" }\n",
" (() => {\n",
" let quickchartButtonEl =\n",
" document.querySelector('#df-d056786c-bbf1-4c9d-86ac-295a05c72465 button');\n",
" quickchartButtonEl.style.display =\n",
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
" })();\n",
" </script>\n",
"</div>\n",
" </div>\n",
" </div>\n"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "dataframe"
}
},
"metadata": {},
"execution_count": 8
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "vtYDmGTeW0cS",
"outputId": "7aace334-992b-4433-cc64-93fe34f2613f",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 363
}
},
"source": [
"summary2 = summary_hourly(dataset, 'AURENE', n_hours=10, text_date=['Tanggal', 'Jam'], date_format='%d %b %Y', hour_format='%I:%M %p')\n",
"summary2.sample(n=10)"
],
"execution_count": 11,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" Tanggal Jam 1 2 3 4 5 6 7 8 9 10\n",
"15470 06 Oct 2001 05:00 PM 0.7 NaN NaN NaN NaN NaN NaN NaN NaN NaN\n",
"18700 18 Feb 2002 04:00 AM 2.2 2.3 NaN NaN NaN NaN NaN NaN NaN NaN\n",
"7350 02 Nov 2000 06:00 AM 2.2 0.2 NaN NaN NaN NaN NaN NaN NaN NaN\n",
"21200 02 Jun 2002 10:00 AM 13.6 NaN NaN NaN NaN NaN NaN NaN NaN NaN\n",
"17120 14 Dec 2001 08:00 AM 0.9 NaN NaN NaN NaN NaN NaN NaN NaN NaN\n",
"2710 23 Apr 2000 06:00 AM 4.5 NaN NaN NaN NaN NaN NaN NaN NaN NaN\n",
"9790 12 Feb 2001 12:00 AM 3.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN\n",
"15850 22 Oct 2001 12:00 PM 9.4 1.4 0.4 0.6 NaN NaN NaN NaN NaN NaN\n",
"18140 26 Jan 2002 05:00 AM 0.2 NaN NaN NaN NaN NaN NaN NaN NaN NaN\n",
"2880 30 Apr 2000 05:00 AM 40.0 17.0 0.5 NaN NaN NaN NaN NaN NaN NaN"
],
"text/html": [
"\n",
" <div id=\"df-002b57fd-a33b-48ee-b056-a8e9473fdb28\" class=\"colab-df-container\">\n",
" <div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Tanggal</th>\n",
" <th>Jam</th>\n",
" <th>1</th>\n",
" <th>2</th>\n",
" <th>3</th>\n",
" <th>4</th>\n",
" <th>5</th>\n",
" <th>6</th>\n",
" <th>7</th>\n",
" <th>8</th>\n",
" <th>9</th>\n",
" <th>10</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>15470</th>\n",
" <td>06 Oct 2001</td>\n",
" <td>05:00 PM</td>\n",
" <td>0.7</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18700</th>\n",
" <td>18 Feb 2002</td>\n",
" <td>04:00 AM</td>\n",
" <td>2.2</td>\n",
" <td>2.3</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7350</th>\n",
" <td>02 Nov 2000</td>\n",
" <td>06:00 AM</td>\n",
" <td>2.2</td>\n",
" <td>0.2</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21200</th>\n",
" <td>02 Jun 2002</td>\n",
" <td>10:00 AM</td>\n",
" <td>13.6</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17120</th>\n",
" <td>14 Dec 2001</td>\n",
" <td>08:00 AM</td>\n",
" <td>0.9</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2710</th>\n",
" <td>23 Apr 2000</td>\n",
" <td>06:00 AM</td>\n",
" <td>4.5</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9790</th>\n",
" <td>12 Feb 2001</td>\n",
" <td>12:00 AM</td>\n",
" <td>3.0</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15850</th>\n",
" <td>22 Oct 2001</td>\n",
" <td>12:00 PM</td>\n",
" <td>9.4</td>\n",
" <td>1.4</td>\n",
" <td>0.4</td>\n",
" <td>0.6</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18140</th>\n",
" <td>26 Jan 2002</td>\n",
" <td>05:00 AM</td>\n",
" <td>0.2</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2880</th>\n",
" <td>30 Apr 2000</td>\n",
" <td>05:00 AM</td>\n",
" <td>40.0</td>\n",
" <td>17.0</td>\n",
" <td>0.5</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>\n",
" <div class=\"colab-df-buttons\">\n",
"\n",
" <div class=\"colab-df-container\">\n",
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-002b57fd-a33b-48ee-b056-a8e9473fdb28')\"\n",
" title=\"Convert this dataframe to an interactive table.\"\n",
" style=\"display:none;\">\n",
"\n",
" <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
" <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
" </svg>\n",
" </button>\n",
"\n",
" <style>\n",
" .colab-df-container {\n",
" display:flex;\n",
" gap: 12px;\n",
" }\n",
"\n",
" .colab-df-convert {\n",
" background-color: #E8F0FE;\n",
" border: none;\n",
" border-radius: 50%;\n",
" cursor: pointer;\n",
" display: none;\n",
" fill: #1967D2;\n",
" height: 32px;\n",
" padding: 0 0 0 0;\n",
" width: 32px;\n",
" }\n",
"\n",
" .colab-df-convert:hover {\n",
" background-color: #E2EBFA;\n",
" box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
" fill: #174EA6;\n",
" }\n",
"\n",
" .colab-df-buttons div {\n",
" margin-bottom: 4px;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-convert {\n",
" background-color: #3B4455;\n",
" fill: #D2E3FC;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-convert:hover {\n",
" background-color: #434B5C;\n",
" box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
" filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
" fill: #FFFFFF;\n",
" }\n",
" </style>\n",
"\n",
" <script>\n",
" const buttonEl =\n",
" document.querySelector('#df-002b57fd-a33b-48ee-b056-a8e9473fdb28 button.colab-df-convert');\n",
" buttonEl.style.display =\n",
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
"\n",
" async function convertToInteractive(key) {\n",
" const element = document.querySelector('#df-002b57fd-a33b-48ee-b056-a8e9473fdb28');\n",
" const dataTable =\n",
" await google.colab.kernel.invokeFunction('convertToInteractive',\n",
" [key], {});\n",
" if (!dataTable) return;\n",
"\n",
" const docLinkHtml = 'Like what you see? Visit the ' +\n",
" '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
" + ' to learn more about interactive tables.';\n",
" element.innerHTML = '';\n",
" dataTable['output_type'] = 'display_data';\n",
" await google.colab.output.renderOutput(dataTable, element);\n",
" const docLink = document.createElement('div');\n",
" docLink.innerHTML = docLinkHtml;\n",
" element.appendChild(docLink);\n",
" }\n",
" </script>\n",
" </div>\n",
"\n",
"\n",
"<div id=\"df-357768ff-1ca5-48ae-a420-9e744702d7a4\">\n",
" <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-357768ff-1ca5-48ae-a420-9e744702d7a4')\"\n",
" title=\"Suggest charts\"\n",
" style=\"display:none;\">\n",
"\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
" width=\"24px\">\n",
" <g>\n",
" <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
" </g>\n",
"</svg>\n",
" </button>\n",
"\n",
"<style>\n",
" .colab-df-quickchart {\n",
" --bg-color: #E8F0FE;\n",
" --fill-color: #1967D2;\n",
" --hover-bg-color: #E2EBFA;\n",
" --hover-fill-color: #174EA6;\n",
" --disabled-fill-color: #AAA;\n",
" --disabled-bg-color: #DDD;\n",
" }\n",
"\n",
" [theme=dark] .colab-df-quickchart {\n",
" --bg-color: #3B4455;\n",
" --fill-color: #D2E3FC;\n",
" --hover-bg-color: #434B5C;\n",
" --hover-fill-color: #FFFFFF;\n",
" --disabled-bg-color: #3B4455;\n",
" --disabled-fill-color: #666;\n",
" }\n",
"\n",
" .colab-df-quickchart {\n",
" background-color: var(--bg-color);\n",
" border: none;\n",
" border-radius: 50%;\n",
" cursor: pointer;\n",
" display: none;\n",
" fill: var(--fill-color);\n",
" height: 32px;\n",
" padding: 0;\n",
" width: 32px;\n",
" }\n",
"\n",
" .colab-df-quickchart:hover {\n",
" background-color: var(--hover-bg-color);\n",
" box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
" fill: var(--button-hover-fill-color);\n",
" }\n",
"\n",
" .colab-df-quickchart-complete:disabled,\n",
" .colab-df-quickchart-complete:disabled:hover {\n",
" background-color: var(--disabled-bg-color);\n",
" fill: var(--disabled-fill-color);\n",
" box-shadow: none;\n",
" }\n",
"\n",
" .colab-df-spinner {\n",
" border: 2px solid var(--fill-color);\n",
" border-color: transparent;\n",
" border-bottom-color: var(--fill-color);\n",
" animation:\n",
" spin 1s steps(1) infinite;\n",
" }\n",
"\n",
" @keyframes spin {\n",
" 0% {\n",
" border-color: transparent;\n",
" border-bottom-color: var(--fill-color);\n",
" border-left-color: var(--fill-color);\n",
" }\n",
" 20% {\n",
" border-color: transparent;\n",
" border-left-color: var(--fill-color);\n",
" border-top-color: var(--fill-color);\n",
" }\n",
" 30% {\n",
" border-color: transparent;\n",
" border-left-color: var(--fill-color);\n",
" border-top-color: var(--fill-color);\n",
" border-right-color: var(--fill-color);\n",
" }\n",
" 40% {\n",
" border-color: transparent;\n",
" border-right-color: var(--fill-color);\n",
" border-top-color: var(--fill-color);\n",
" }\n",
" 60% {\n",
" border-color: transparent;\n",
" border-right-color: var(--fill-color);\n",
" }\n",
" 80% {\n",
" border-color: transparent;\n",
" border-right-color: var(--fill-color);\n",
" border-bottom-color: var(--fill-color);\n",
" }\n",
" 90% {\n",
" border-color: transparent;\n",
" border-bottom-color: var(--fill-color);\n",
" }\n",
" }\n",
"</style>\n",
"\n",
" <script>\n",
" async function quickchart(key) {\n",
" const quickchartButtonEl =\n",
" document.querySelector('#' + key + ' button');\n",
" quickchartButtonEl.disabled = true; // To prevent multiple clicks.\n",
" quickchartButtonEl.classList.add('colab-df-spinner');\n",
" try {\n",
" const charts = await google.colab.kernel.invokeFunction(\n",
" 'suggestCharts', [key], {});\n",
" } catch (error) {\n",
" console.error('Error during call to suggestCharts:', error);\n",
" }\n",
" quickchartButtonEl.classList.remove('colab-df-spinner');\n",
" quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
" }\n",
" (() => {\n",
" let quickchartButtonEl =\n",
" document.querySelector('#df-357768ff-1ca5-48ae-a420-9e744702d7a4 button');\n",
" quickchartButtonEl.style.display =\n",
" google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
" })();\n",
" </script>\n",
"</div>\n",
" </div>\n",
" </div>\n"
],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "dataframe",
"repr_error": "0"
}
},
"metadata": {},
"execution_count": 11
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "xtlMdmTlhShI",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "ccffe276-fe40-4c7b-9286-c9546f8684a0"
},
"source": [
"summary3 = summary_hourly(dataset, 'AURENE', n_hours=24, return_as_dataframe=False)\n",
"print(type(summary3))\n",
"print(len(summary3.keys()))\n",
"print(list(summary3.keys())[:10])"
],
"execution_count": 12,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"<class 'dict'>\n",
"1093\n",
"[0, 24, 48, 49, 50, 72, 96, 97, 120, 144]\n"
]
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "EhPfCQ6LVZYK"
},
"source": [
"# Changelog\n",
"\n",
"```\n",
"- 20240414 - 1.1.0 / 0.5.0 - Refactor hk84\n",
"- 20191209 - 1.0.0 - Initial\n",
"```\n",
"\n",
"#### Copyright &copy; 2019-2024 [Taruma Sakti Megariansyah](https://taruma.github.io)\n",
"\n",
"Source code in this notebook is licensed under a [MIT License](https://choosealicense.com/licenses/mit/). Data in this notebook is licensed under a [Creative Common Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/).\n"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment