{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "import awswrangler as wr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<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>device_id</th>\n",
       "      <th>sk</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>model</th>\n",
       "      <th>id</th>\n",
       "      <th>e_type</th>\n",
       "      <th>battery</th>\n",
       "      <th>status</th>\n",
       "      <th>evt</th>\n",
       "      <th>year</th>\n",
       "      <th>month</th>\n",
       "      <th>day</th>\n",
       "      <th>hour</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>00158d0006c9d5ed</td>\n",
       "      <td>1638142531000</td>\n",
       "      <td>2021-11-29 08:35:31</td>\n",
       "      <td>a2_sen_cds_01</td>\n",
       "      <td>c5a28dfd</td>\n",
       "      <td>reported</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>00158d0006c9d5ed</td>\n",
       "      <td>1638138628000</td>\n",
       "      <td>2021-11-29 07:30:28</td>\n",
       "      <td>a2_sen_cds_01</td>\n",
       "      <td>339ffde9</td>\n",
       "      <td>reported</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>00158d0006c9d5ed</td>\n",
       "      <td>1638134714000</td>\n",
       "      <td>2021-11-29 06:25:14</td>\n",
       "      <td>a2_sen_cds_01</td>\n",
       "      <td>2dfd69c4</td>\n",
       "      <td>reported</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>00158d0006c9d5ed</td>\n",
       "      <td>1638130206000</td>\n",
       "      <td>2021-11-29 05:10:06</td>\n",
       "      <td>a2_sen_cds_01</td>\n",
       "      <td>55fcca49</td>\n",
       "      <td>reported</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>00158d0006c9d5ed</td>\n",
       "      <td>1637987718000</td>\n",
       "      <td>2021-11-27 13:35:18</td>\n",
       "      <td>a2_sen_cds_01</td>\n",
       "      <td>07cd0ed4</td>\n",
       "      <td>reported</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>27</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>00158d0006c9d5ed</td>\n",
       "      <td>1637970265000</td>\n",
       "      <td>2021-11-27 08:44:25</td>\n",
       "      <td>a2_sen_cds_01</td>\n",
       "      <td>0134f2c3</td>\n",
       "      <td>reported</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>27</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>00158d0006c9d5ed</td>\n",
       "      <td>1637965751000</td>\n",
       "      <td>2021-11-27 07:29:11</td>\n",
       "      <td>a2_sen_cds_01</td>\n",
       "      <td>83daa627</td>\n",
       "      <td>reported</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>27</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>00158d0006c9d5ed</td>\n",
       "      <td>1637939559000</td>\n",
       "      <td>2021-11-27 00:12:39</td>\n",
       "      <td>a2_sen_cds_01</td>\n",
       "      <td>4278c321</td>\n",
       "      <td>reported</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>27</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>00158d0006c9d5ed</td>\n",
       "      <td>1637917262000</td>\n",
       "      <td>2021-11-26 18:01:02</td>\n",
       "      <td>a2_sen_cds_01</td>\n",
       "      <td>7a458c00</td>\n",
       "      <td>reported</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>26</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>00158d0006c9d5ed</td>\n",
       "      <td>1637915754000</td>\n",
       "      <td>2021-11-26 17:35:54</td>\n",
       "      <td>a2_sen_cds_01</td>\n",
       "      <td>278d125a</td>\n",
       "      <td>reported</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>26</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          device_id             sk            timestamp          model  \\\n",
       "0  00158d0006c9d5ed  1638142531000  2021-11-29 08:35:31  a2_sen_cds_01   \n",
       "1  00158d0006c9d5ed  1638138628000  2021-11-29 07:30:28  a2_sen_cds_01   \n",
       "2  00158d0006c9d5ed  1638134714000  2021-11-29 06:25:14  a2_sen_cds_01   \n",
       "3  00158d0006c9d5ed  1638130206000  2021-11-29 05:10:06  a2_sen_cds_01   \n",
       "4  00158d0006c9d5ed  1637987718000  2021-11-27 13:35:18  a2_sen_cds_01   \n",
       "5  00158d0006c9d5ed  1637970265000  2021-11-27 08:44:25  a2_sen_cds_01   \n",
       "6  00158d0006c9d5ed  1637965751000  2021-11-27 07:29:11  a2_sen_cds_01   \n",
       "7  00158d0006c9d5ed  1637939559000  2021-11-27 00:12:39  a2_sen_cds_01   \n",
       "8  00158d0006c9d5ed  1637917262000  2021-11-26 18:01:02  a2_sen_cds_01   \n",
       "9  00158d0006c9d5ed  1637915754000  2021-11-26 17:35:54  a2_sen_cds_01   \n",
       "\n",
       "         id    e_type  battery  status  evt  year month day hour  \n",
       "0  c5a28dfd  reported        6       1    6  2021    11  29    8  \n",
       "1  339ffde9  reported        6       1    1  2021    11  29    7  \n",
       "2  2dfd69c4  reported        6       1    1  2021    11  29    6  \n",
       "3  55fcca49  reported        6       1    1  2021    11  29    5  \n",
       "4  07cd0ed4  reported        6       1    1  2021    11  27   13  \n",
       "5  0134f2c3  reported        6       1    1  2021    11  27    8  \n",
       "6  83daa627  reported        6       1    1  2021    11  27    7  \n",
       "7  4278c321  reported        6       1    1  2021    11  27    0  \n",
       "8  7a458c00  reported        6       1    1  2021    11  26   18  \n",
       "9  278d125a  reported        6       1    6  2021    11  26   17  "
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = wr.athena.read_sql_query(\n",
    "    sql=\"SELECT * FROM illumination where device_id = '00158d0006c9d5ed' order by timestamp desc limit 10 /*3회의실조도센서*/;\",\n",
    "    database=\"ambt_b2c\"\n",
    ")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<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>device_id</th>\n",
       "      <th>sk</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>model</th>\n",
       "      <th>id</th>\n",
       "      <th>e_type</th>\n",
       "      <th>hum</th>\n",
       "      <th>temp</th>\n",
       "      <th>battery</th>\n",
       "      <th>status</th>\n",
       "      <th>year</th>\n",
       "      <th>month</th>\n",
       "      <th>day</th>\n",
       "      <th>hour</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>00158d00028d93d8</td>\n",
       "      <td>1638146954000</td>\n",
       "      <td>2021-11-29 09:49:14</td>\n",
       "      <td>a2_sen_th_01</td>\n",
       "      <td>fdc93e9c</td>\n",
       "      <td>reported</td>\n",
       "      <td>26</td>\n",
       "      <td>249</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>00158d00028d93d8</td>\n",
       "      <td>1638146954000</td>\n",
       "      <td>2021-11-29 09:49:14</td>\n",
       "      <td>a2_sen_th_01</td>\n",
       "      <td>a6fa9718</td>\n",
       "      <td>reported</td>\n",
       "      <td>25</td>\n",
       "      <td>249</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>00158d00028d93d8</td>\n",
       "      <td>1638146653000</td>\n",
       "      <td>2021-11-29 09:44:13</td>\n",
       "      <td>a2_sen_th_01</td>\n",
       "      <td>19295a0d</td>\n",
       "      <td>reported</td>\n",
       "      <td>26</td>\n",
       "      <td>244</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>00158d00028d93d8</td>\n",
       "      <td>1638146362000</td>\n",
       "      <td>2021-11-29 09:39:22</td>\n",
       "      <td>a2_sen_th_01</td>\n",
       "      <td>5fc92dc4</td>\n",
       "      <td>reported</td>\n",
       "      <td>27</td>\n",
       "      <td>240</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>00158d00028d93d8</td>\n",
       "      <td>1638146057000</td>\n",
       "      <td>2021-11-29 09:34:17</td>\n",
       "      <td>a2_sen_th_01</td>\n",
       "      <td>6393c2bc</td>\n",
       "      <td>reported</td>\n",
       "      <td>27</td>\n",
       "      <td>234</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>00158d00028d93d8</td>\n",
       "      <td>1638146056000</td>\n",
       "      <td>2021-11-29 09:34:16</td>\n",
       "      <td>a2_sen_th_01</td>\n",
       "      <td>5f518e6c</td>\n",
       "      <td>reported</td>\n",
       "      <td>28</td>\n",
       "      <td>234</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>00158d00028d93d8</td>\n",
       "      <td>1638145756000</td>\n",
       "      <td>2021-11-29 09:29:16</td>\n",
       "      <td>a2_sen_th_01</td>\n",
       "      <td>87312dd5</td>\n",
       "      <td>reported</td>\n",
       "      <td>28</td>\n",
       "      <td>227</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>00158d00028d93d8</td>\n",
       "      <td>1638145751000</td>\n",
       "      <td>2021-11-29 09:29:11</td>\n",
       "      <td>a2_sen_th_01</td>\n",
       "      <td>78ccec5f</td>\n",
       "      <td>reported</td>\n",
       "      <td>29</td>\n",
       "      <td>227</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>00158d00028d93d8</td>\n",
       "      <td>1638145451000</td>\n",
       "      <td>2021-11-29 09:24:11</td>\n",
       "      <td>a2_sen_th_01</td>\n",
       "      <td>2967d0b3</td>\n",
       "      <td>reported</td>\n",
       "      <td>29</td>\n",
       "      <td>219</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>00158d00028d93d8</td>\n",
       "      <td>1638145150000</td>\n",
       "      <td>2021-11-29 09:19:10</td>\n",
       "      <td>a2_sen_th_01</td>\n",
       "      <td>7d5f4627</td>\n",
       "      <td>reported</td>\n",
       "      <td>29</td>\n",
       "      <td>211</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          device_id             sk            timestamp         model  \\\n",
       "0  00158d00028d93d8  1638146954000  2021-11-29 09:49:14  a2_sen_th_01   \n",
       "1  00158d00028d93d8  1638146954000  2021-11-29 09:49:14  a2_sen_th_01   \n",
       "2  00158d00028d93d8  1638146653000  2021-11-29 09:44:13  a2_sen_th_01   \n",
       "3  00158d00028d93d8  1638146362000  2021-11-29 09:39:22  a2_sen_th_01   \n",
       "4  00158d00028d93d8  1638146057000  2021-11-29 09:34:17  a2_sen_th_01   \n",
       "5  00158d00028d93d8  1638146056000  2021-11-29 09:34:16  a2_sen_th_01   \n",
       "6  00158d00028d93d8  1638145756000  2021-11-29 09:29:16  a2_sen_th_01   \n",
       "7  00158d00028d93d8  1638145751000  2021-11-29 09:29:11  a2_sen_th_01   \n",
       "8  00158d00028d93d8  1638145451000  2021-11-29 09:24:11  a2_sen_th_01   \n",
       "9  00158d00028d93d8  1638145150000  2021-11-29 09:19:10  a2_sen_th_01   \n",
       "\n",
       "         id    e_type  hum  temp  battery  status  year month day hour  \n",
       "0  fdc93e9c  reported   26   249        0       1  2021    11  29    9  \n",
       "1  a6fa9718  reported   25   249        0       1  2021    11  29    9  \n",
       "2  19295a0d  reported   26   244        0       1  2021    11  29    9  \n",
       "3  5fc92dc4  reported   27   240        0       1  2021    11  29    9  \n",
       "4  6393c2bc  reported   27   234        0       1  2021    11  29    9  \n",
       "5  5f518e6c  reported   28   234        0       1  2021    11  29    9  \n",
       "6  87312dd5  reported   28   227        0       1  2021    11  29    9  \n",
       "7  78ccec5f  reported   29   227        0       1  2021    11  29    9  \n",
       "8  2967d0b3  reported   29   219        0       1  2021    11  29    9  \n",
       "9  7d5f4627  reported   29   211        0       1  2021    11  29    9  "
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = wr.athena.read_sql_query(\n",
    "    sql=\"SELECT * FROM temperature_humidity where device_id = '00158d00028d93d8' order by timestamp desc limit 10 /*3회의실온습도센서*/;\",\n",
    "    database=\"ambt_b2c\"\n",
    ")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<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>device_id</th>\n",
       "      <th>sk</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>model</th>\n",
       "      <th>id</th>\n",
       "      <th>e_type</th>\n",
       "      <th>battery</th>\n",
       "      <th>status</th>\n",
       "      <th>evt</th>\n",
       "      <th>year</th>\n",
       "      <th>month</th>\n",
       "      <th>day</th>\n",
       "      <th>hour</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>00158d0002d545b4</td>\n",
       "      <td>1638250408000</td>\n",
       "      <td>2021-11-30 14:33:28</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>72e2d749</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>00158d0002d545b4</td>\n",
       "      <td>1638248702000</td>\n",
       "      <td>2021-11-30 14:05:02</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>7f6500ba</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>00158d0002d545b4</td>\n",
       "      <td>1637913814000</td>\n",
       "      <td>2021-11-26 17:03:34</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>7374a99b</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>26</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>00158d0002d545b4</td>\n",
       "      <td>1637906976000</td>\n",
       "      <td>2021-11-26 15:09:36</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>fc6ef1ed</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>26</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>00158d0002d545b4</td>\n",
       "      <td>1637905314000</td>\n",
       "      <td>2021-11-26 14:41:54</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>3fff6d7f</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>26</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>00158d0002d545b4</td>\n",
       "      <td>1637904052000</td>\n",
       "      <td>2021-11-26 14:20:52</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>df21c92d</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>26</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>00158d0002d545b4</td>\n",
       "      <td>1637885207000</td>\n",
       "      <td>2021-11-26 09:06:47</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>54b9e9b2</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>26</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>00158d0002d545b4</td>\n",
       "      <td>1637882804000</td>\n",
       "      <td>2021-11-26 08:26:44</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>f156880a</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>26</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>00158d0002d545b4</td>\n",
       "      <td>1637882445000</td>\n",
       "      <td>2021-11-26 08:20:45</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>622e4ab9</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>26</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>00158d0002d545b4</td>\n",
       "      <td>1637881650000</td>\n",
       "      <td>2021-11-26 08:07:30</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>b5c40bab</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>26</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          device_id             sk            timestamp         model  \\\n",
       "0  00158d0002d545b4  1638250408000  2021-11-30 14:33:28  a2_sen_mt_01   \n",
       "1  00158d0002d545b4  1638248702000  2021-11-30 14:05:02  a2_sen_mt_01   \n",
       "2  00158d0002d545b4  1637913814000  2021-11-26 17:03:34  a2_sen_mt_01   \n",
       "3  00158d0002d545b4  1637906976000  2021-11-26 15:09:36  a2_sen_mt_01   \n",
       "4  00158d0002d545b4  1637905314000  2021-11-26 14:41:54  a2_sen_mt_01   \n",
       "5  00158d0002d545b4  1637904052000  2021-11-26 14:20:52  a2_sen_mt_01   \n",
       "6  00158d0002d545b4  1637885207000  2021-11-26 09:06:47  a2_sen_mt_01   \n",
       "7  00158d0002d545b4  1637882804000  2021-11-26 08:26:44  a2_sen_mt_01   \n",
       "8  00158d0002d545b4  1637882445000  2021-11-26 08:20:45  a2_sen_mt_01   \n",
       "9  00158d0002d545b4  1637881650000  2021-11-26 08:07:30  a2_sen_mt_01   \n",
       "\n",
       "         id    e_type  battery  status  evt  year month day hour  \n",
       "0  72e2d749  reported        0       1    1  2021    11  30   14  \n",
       "1  7f6500ba  reported        0       1    1  2021    11  30   14  \n",
       "2  7374a99b  reported        0       1    1  2021    11  26   17  \n",
       "3  fc6ef1ed  reported        0       1    1  2021    11  26   15  \n",
       "4  3fff6d7f  reported        0       1    1  2021    11  26   14  \n",
       "5  df21c92d  reported        0       1    1  2021    11  26   14  \n",
       "6  54b9e9b2  reported        0       1    1  2021    11  26    9  \n",
       "7  f156880a  reported        0       1    1  2021    11  26    8  \n",
       "8  622e4ab9  reported        0       1    1  2021    11  26    8  \n",
       "9  b5c40bab  reported        0       1    1  2021    11  26    8  "
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = wr.athena.read_sql_query(\n",
    "    sql=\"SELECT * FROM motion_door where device_id = '00158d0002d545b4' order by timestamp desc limit 10 /*3회의실모션센서*/;\",\n",
    "    database=\"ambt_b2c\"\n",
    ")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<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>device_id</th>\n",
       "      <th>sk</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>model</th>\n",
       "      <th>id</th>\n",
       "      <th>e_type</th>\n",
       "      <th>battery</th>\n",
       "      <th>status</th>\n",
       "      <th>evt</th>\n",
       "      <th>year</th>\n",
       "      <th>month</th>\n",
       "      <th>day</th>\n",
       "      <th>hour</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>00158d0005bb96f3</td>\n",
       "      <td>1638250388000</td>\n",
       "      <td>2021-11-30 14:33:08</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>5eb49bb8</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>00158d0005bb96f3</td>\n",
       "      <td>1638146963000</td>\n",
       "      <td>2021-11-29 09:49:23</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>0ee044e5</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>00158d0005bb96f3</td>\n",
       "      <td>1638145524000</td>\n",
       "      <td>2021-11-29 09:25:24</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>bced6030</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>00158d0005bb96f3</td>\n",
       "      <td>1638145260000</td>\n",
       "      <td>2021-11-29 09:21:00</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>dcc754bc</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>00158d0005bb96f3</td>\n",
       "      <td>1638145039000</td>\n",
       "      <td>2021-11-29 09:17:19</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>5ee6843e</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>00158d0005bb96f3</td>\n",
       "      <td>1638145035000</td>\n",
       "      <td>2021-11-29 09:17:15</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>274ec676</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>00158d0005bb96f3</td>\n",
       "      <td>1638144390000</td>\n",
       "      <td>2021-11-29 09:06:30</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>ffb89511</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>00158d0005bb96f3</td>\n",
       "      <td>1638142790000</td>\n",
       "      <td>2021-11-29 08:39:50</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>cc1f5fdb</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>00158d0005bb96f3</td>\n",
       "      <td>1638142526000</td>\n",
       "      <td>2021-11-29 08:35:26</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>16e525f4</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>00158d0005bb96f3</td>\n",
       "      <td>1637913816000</td>\n",
       "      <td>2021-11-26 17:03:36</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>7c29c17d</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>26</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          device_id             sk            timestamp          model  \\\n",
       "0  00158d0005bb96f3  1638250388000  2021-11-30 14:33:08  a2_sen_dor_01   \n",
       "1  00158d0005bb96f3  1638146963000  2021-11-29 09:49:23  a2_sen_dor_01   \n",
       "2  00158d0005bb96f3  1638145524000  2021-11-29 09:25:24  a2_sen_dor_01   \n",
       "3  00158d0005bb96f3  1638145260000  2021-11-29 09:21:00  a2_sen_dor_01   \n",
       "4  00158d0005bb96f3  1638145039000  2021-11-29 09:17:19  a2_sen_dor_01   \n",
       "5  00158d0005bb96f3  1638145035000  2021-11-29 09:17:15  a2_sen_dor_01   \n",
       "6  00158d0005bb96f3  1638144390000  2021-11-29 09:06:30  a2_sen_dor_01   \n",
       "7  00158d0005bb96f3  1638142790000  2021-11-29 08:39:50  a2_sen_dor_01   \n",
       "8  00158d0005bb96f3  1638142526000  2021-11-29 08:35:26  a2_sen_dor_01   \n",
       "9  00158d0005bb96f3  1637913816000  2021-11-26 17:03:36  a2_sen_dor_01   \n",
       "\n",
       "         id    e_type  battery  status  evt  year month day hour  \n",
       "0  5eb49bb8  reported        0       1    0  2021    11  30   14  \n",
       "1  0ee044e5  reported        0       1    1  2021    11  29    9  \n",
       "2  bced6030  reported        0       1    0  2021    11  29    9  \n",
       "3  dcc754bc  reported        0       1    1  2021    11  29    9  \n",
       "4  5ee6843e  reported        0       1    0  2021    11  29    9  \n",
       "5  274ec676  reported        0       1    1  2021    11  29    9  \n",
       "6  ffb89511  reported        0       1    0  2021    11  29    9  \n",
       "7  cc1f5fdb  reported        0       1    1  2021    11  29    8  \n",
       "8  16e525f4  reported        0       1    0  2021    11  29    8  \n",
       "9  7c29c17d  reported        0       1    1  2021    11  26   17  "
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = wr.athena.read_sql_query(\n",
    "    sql=\"SELECT * FROM motion_door where device_id = '00158d0005bb96f3' order by timestamp desc limit 10 /*3회의실문열림센서*/;\",\n",
    "    database=\"ambt_b2c\"\n",
    ")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<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>device_id</th>\n",
       "      <th>sk</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>model</th>\n",
       "      <th>id</th>\n",
       "      <th>e_type</th>\n",
       "      <th>battery</th>\n",
       "      <th>status</th>\n",
       "      <th>evt</th>\n",
       "      <th>year</th>\n",
       "      <th>month</th>\n",
       "      <th>day</th>\n",
       "      <th>hour</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>00158d0005a9998b</td>\n",
       "      <td>1638246272000</td>\n",
       "      <td>2021-11-30 13:24:32</td>\n",
       "      <td>a2_sen_cds_01</td>\n",
       "      <td>93f9369c</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>9</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>00158d0005a9998b</td>\n",
       "      <td>1638244831000</td>\n",
       "      <td>2021-11-30 13:00:31</td>\n",
       "      <td>a2_sen_cds_01</td>\n",
       "      <td>601c4eea</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>10</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>00158d0005a9998b</td>\n",
       "      <td>1638244822000</td>\n",
       "      <td>2021-11-30 13:00:22</td>\n",
       "      <td>a2_sen_cds_01</td>\n",
       "      <td>7abd863e</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>9</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>00158d0005a9998b</td>\n",
       "      <td>1638244791000</td>\n",
       "      <td>2021-11-30 12:59:51</td>\n",
       "      <td>a2_sen_cds_01</td>\n",
       "      <td>ae4e0806</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>00158d0005a9998b</td>\n",
       "      <td>1638244781000</td>\n",
       "      <td>2021-11-30 12:59:41</td>\n",
       "      <td>a2_sen_cds_01</td>\n",
       "      <td>129de4ae</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>00158d0005a9998b</td>\n",
       "      <td>1638244499000</td>\n",
       "      <td>2021-11-30 12:54:59</td>\n",
       "      <td>a2_sen_cds_01</td>\n",
       "      <td>cc8ff83e</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>00158d0005a9998b</td>\n",
       "      <td>1638244489000</td>\n",
       "      <td>2021-11-30 12:54:49</td>\n",
       "      <td>a2_sen_cds_01</td>\n",
       "      <td>e821a0ed</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>00158d0005a9998b</td>\n",
       "      <td>1638244479000</td>\n",
       "      <td>2021-11-30 12:54:39</td>\n",
       "      <td>a2_sen_cds_01</td>\n",
       "      <td>147ee512</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>00158d0005a9998b</td>\n",
       "      <td>1638244419000</td>\n",
       "      <td>2021-11-30 12:53:39</td>\n",
       "      <td>a2_sen_cds_01</td>\n",
       "      <td>b9431dfe</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>00158d0005a9998b</td>\n",
       "      <td>1638244358000</td>\n",
       "      <td>2021-11-30 12:52:38</td>\n",
       "      <td>a2_sen_cds_01</td>\n",
       "      <td>7d9eb350</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>12</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          device_id             sk            timestamp          model  \\\n",
       "0  00158d0005a9998b  1638246272000  2021-11-30 13:24:32  a2_sen_cds_01   \n",
       "1  00158d0005a9998b  1638244831000  2021-11-30 13:00:31  a2_sen_cds_01   \n",
       "2  00158d0005a9998b  1638244822000  2021-11-30 13:00:22  a2_sen_cds_01   \n",
       "3  00158d0005a9998b  1638244791000  2021-11-30 12:59:51  a2_sen_cds_01   \n",
       "4  00158d0005a9998b  1638244781000  2021-11-30 12:59:41  a2_sen_cds_01   \n",
       "5  00158d0005a9998b  1638244499000  2021-11-30 12:54:59  a2_sen_cds_01   \n",
       "6  00158d0005a9998b  1638244489000  2021-11-30 12:54:49  a2_sen_cds_01   \n",
       "7  00158d0005a9998b  1638244479000  2021-11-30 12:54:39  a2_sen_cds_01   \n",
       "8  00158d0005a9998b  1638244419000  2021-11-30 12:53:39  a2_sen_cds_01   \n",
       "9  00158d0005a9998b  1638244358000  2021-11-30 12:52:38  a2_sen_cds_01   \n",
       "\n",
       "         id    e_type  battery  status  evt  year month day hour  \n",
       "0  93f9369c  reported        0       1    9  2021    11  30   13  \n",
       "1  601c4eea  reported        0       1   10  2021    11  30   13  \n",
       "2  7abd863e  reported        0       1    9  2021    11  30   13  \n",
       "3  ae4e0806  reported        0       1    4  2021    11  30   12  \n",
       "4  129de4ae  reported        0       1    5  2021    11  30   12  \n",
       "5  cc8ff83e  reported        0       1    4  2021    11  30   12  \n",
       "6  e821a0ed  reported        0       1    3  2021    11  30   12  \n",
       "7  147ee512  reported        0       1    4  2021    11  30   12  \n",
       "8  b9431dfe  reported        0       1    3  2021    11  30   12  \n",
       "9  7d9eb350  reported        0       1    4  2021    11  30   12  "
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = wr.athena.read_sql_query(\n",
    "    sql=\"SELECT * FROM illumination where device_id = '00158d0005a9998b' order by timestamp desc limit 10 /*연구소조도센서*/;\",\n",
    "    database=\"ambt_b2c\"\n",
    ")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<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>device_id</th>\n",
       "      <th>sk</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>model</th>\n",
       "      <th>id</th>\n",
       "      <th>e_type</th>\n",
       "      <th>battery</th>\n",
       "      <th>status</th>\n",
       "      <th>evt</th>\n",
       "      <th>year</th>\n",
       "      <th>month</th>\n",
       "      <th>day</th>\n",
       "      <th>hour</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>00158d0002cab225</td>\n",
       "      <td>1638248019000</td>\n",
       "      <td>2021-11-30 13:53:39</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>1040e7c6</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>00158d0002cab225</td>\n",
       "      <td>1638247475000</td>\n",
       "      <td>2021-11-30 13:44:35</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>4af86acf</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>00158d0002cab225</td>\n",
       "      <td>1638246438000</td>\n",
       "      <td>2021-11-30 13:27:18</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>32b6aa68</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>00158d0002cab225</td>\n",
       "      <td>1638233537000</td>\n",
       "      <td>2021-11-30 09:52:17</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>da53ea05</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>00158d0002cab225</td>\n",
       "      <td>1638231066000</td>\n",
       "      <td>2021-11-30 09:11:06</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>472686d4</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>00158d0002cab225</td>\n",
       "      <td>1638230419000</td>\n",
       "      <td>2021-11-30 09:00:19</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>9018cbfd</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>00158d0002cab225</td>\n",
       "      <td>1638227099000</td>\n",
       "      <td>2021-11-30 08:04:59</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>9b7710a8</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>00158d0002cab225</td>\n",
       "      <td>1638217727000</td>\n",
       "      <td>2021-11-30 05:28:47</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>4805e5b3</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>00158d0002cab225</td>\n",
       "      <td>1638207705000</td>\n",
       "      <td>2021-11-30 02:41:45</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>de5f7e04</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>00158d0002cab225</td>\n",
       "      <td>1638177874000</td>\n",
       "      <td>2021-11-29 18:24:34</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>fa93d91d</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>29</td>\n",
       "      <td>18</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          device_id             sk            timestamp         model  \\\n",
       "0  00158d0002cab225  1638248019000  2021-11-30 13:53:39  a2_sen_mt_01   \n",
       "1  00158d0002cab225  1638247475000  2021-11-30 13:44:35  a2_sen_mt_01   \n",
       "2  00158d0002cab225  1638246438000  2021-11-30 13:27:18  a2_sen_mt_01   \n",
       "3  00158d0002cab225  1638233537000  2021-11-30 09:52:17  a2_sen_mt_01   \n",
       "4  00158d0002cab225  1638231066000  2021-11-30 09:11:06  a2_sen_mt_01   \n",
       "5  00158d0002cab225  1638230419000  2021-11-30 09:00:19  a2_sen_mt_01   \n",
       "6  00158d0002cab225  1638227099000  2021-11-30 08:04:59  a2_sen_mt_01   \n",
       "7  00158d0002cab225  1638217727000  2021-11-30 05:28:47  a2_sen_mt_01   \n",
       "8  00158d0002cab225  1638207705000  2021-11-30 02:41:45  a2_sen_mt_01   \n",
       "9  00158d0002cab225  1638177874000  2021-11-29 18:24:34  a2_sen_mt_01   \n",
       "\n",
       "         id    e_type  battery  status  evt  year month day hour  \n",
       "0  1040e7c6  reported        0       1    1  2021    11  30   13  \n",
       "1  4af86acf  reported        0       1    1  2021    11  30   13  \n",
       "2  32b6aa68  reported        0       1    1  2021    11  30   13  \n",
       "3  da53ea05  reported        0       1    1  2021    11  30    9  \n",
       "4  472686d4  reported        0       1    1  2021    11  30    9  \n",
       "5  9018cbfd  reported        0       1    1  2021    11  30    9  \n",
       "6  9b7710a8  reported        0       1    1  2021    11  30    8  \n",
       "7  4805e5b3  reported        0       1    1  2021    11  30    5  \n",
       "8  de5f7e04  reported        0       1    1  2021    11  30    2  \n",
       "9  fa93d91d  reported        0       1    1  2021    11  29   18  "
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = wr.athena.read_sql_query(\n",
    "    sql=\"SELECT * FROM motion_door where device_id = '00158d0002cab225' order by timestamp desc limit 10 /*연구소모션센서*/;\",\n",
    "    database=\"ambt_b2c\"\n",
    ")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<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>device_id</th>\n",
       "      <th>sk</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>model</th>\n",
       "      <th>id</th>\n",
       "      <th>e_type</th>\n",
       "      <th>battery</th>\n",
       "      <th>status</th>\n",
       "      <th>evt</th>\n",
       "      <th>year</th>\n",
       "      <th>month</th>\n",
       "      <th>day</th>\n",
       "      <th>hour</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>00158d0005bb968a</td>\n",
       "      <td>1638247519000</td>\n",
       "      <td>2021-11-30 13:45:19</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>c4f0d490</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>00158d0005bb968a</td>\n",
       "      <td>1638247514000</td>\n",
       "      <td>2021-11-30 13:45:14</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>24500391</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>00158d0005bb968a</td>\n",
       "      <td>1638247483000</td>\n",
       "      <td>2021-11-30 13:44:43</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>a1f435ab</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>00158d0005bb968a</td>\n",
       "      <td>1638247479000</td>\n",
       "      <td>2021-11-30 13:44:39</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>26db99c3</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>00158d0005bb968a</td>\n",
       "      <td>1638246665000</td>\n",
       "      <td>2021-11-30 13:31:05</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>df9ef5b4</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>00158d0005bb968a</td>\n",
       "      <td>1638246662000</td>\n",
       "      <td>2021-11-30 13:31:02</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>2fa18fc4</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>00158d0005bb968a</td>\n",
       "      <td>1638246449000</td>\n",
       "      <td>2021-11-30 13:27:29</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>c8ad680b</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>00158d0005bb968a</td>\n",
       "      <td>1638246447000</td>\n",
       "      <td>2021-11-30 13:27:27</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>92f56584</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>00158d0005bb968a</td>\n",
       "      <td>1638246130000</td>\n",
       "      <td>2021-11-30 13:22:10</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>ee0271a4</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>00158d0005bb968a</td>\n",
       "      <td>1638246126000</td>\n",
       "      <td>2021-11-30 13:22:06</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>4aaeaed6</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>30</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          device_id             sk            timestamp          model  \\\n",
       "0  00158d0005bb968a  1638247519000  2021-11-30 13:45:19  a2_sen_dor_01   \n",
       "1  00158d0005bb968a  1638247514000  2021-11-30 13:45:14  a2_sen_dor_01   \n",
       "2  00158d0005bb968a  1638247483000  2021-11-30 13:44:43  a2_sen_dor_01   \n",
       "3  00158d0005bb968a  1638247479000  2021-11-30 13:44:39  a2_sen_dor_01   \n",
       "4  00158d0005bb968a  1638246665000  2021-11-30 13:31:05  a2_sen_dor_01   \n",
       "5  00158d0005bb968a  1638246662000  2021-11-30 13:31:02  a2_sen_dor_01   \n",
       "6  00158d0005bb968a  1638246449000  2021-11-30 13:27:29  a2_sen_dor_01   \n",
       "7  00158d0005bb968a  1638246447000  2021-11-30 13:27:27  a2_sen_dor_01   \n",
       "8  00158d0005bb968a  1638246130000  2021-11-30 13:22:10  a2_sen_dor_01   \n",
       "9  00158d0005bb968a  1638246126000  2021-11-30 13:22:06  a2_sen_dor_01   \n",
       "\n",
       "         id    e_type  battery  status  evt  year month day hour  \n",
       "0  c4f0d490  reported        0       1    0  2021    11  30   13  \n",
       "1  24500391  reported        0       1    1  2021    11  30   13  \n",
       "2  a1f435ab  reported        0       1    0  2021    11  30   13  \n",
       "3  26db99c3  reported        0       1    1  2021    11  30   13  \n",
       "4  df9ef5b4  reported        0       1    0  2021    11  30   13  \n",
       "5  2fa18fc4  reported        0       1    1  2021    11  30   13  \n",
       "6  c8ad680b  reported        0       1    0  2021    11  30   13  \n",
       "7  92f56584  reported        0       1    1  2021    11  30   13  \n",
       "8  ee0271a4  reported        0       1    0  2021    11  30   13  \n",
       "9  4aaeaed6  reported        0       1    1  2021    11  30   13  "
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = wr.athena.read_sql_query(\n",
    "    sql=\"SELECT * FROM motion_door where device_id = '00158d0005bb968a' order by timestamp desc limit 10 /*연구소문열림센서*/;\",\n",
    "    database=\"ambt_b2c\"\n",
    ")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<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>device_id</th>\n",
       "      <th>sk</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>model</th>\n",
       "      <th>id</th>\n",
       "      <th>e_type</th>\n",
       "      <th>hum</th>\n",
       "      <th>temp</th>\n",
       "      <th>battery</th>\n",
       "      <th>status</th>\n",
       "      <th>year</th>\n",
       "      <th>month</th>\n",
       "      <th>day</th>\n",
       "      <th>hour</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>00158d00049b8ff3</td>\n",
       "      <td>1637558253000</td>\n",
       "      <td>2021-11-22 14:17:33</td>\n",
       "      <td>a2_sen_th_01</td>\n",
       "      <td>683fa131</td>\n",
       "      <td>reported</td>\n",
       "      <td>29</td>\n",
       "      <td>226</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>22</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>00158d00049b8ff3</td>\n",
       "      <td>1637557952000</td>\n",
       "      <td>2021-11-22 14:12:32</td>\n",
       "      <td>a2_sen_th_01</td>\n",
       "      <td>2ac12530</td>\n",
       "      <td>reported</td>\n",
       "      <td>29</td>\n",
       "      <td>228</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>22</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>00158d00049b8ff3</td>\n",
       "      <td>1637557952000</td>\n",
       "      <td>2021-11-22 14:12:32</td>\n",
       "      <td>a2_sen_th_01</td>\n",
       "      <td>42741e86</td>\n",
       "      <td>reported</td>\n",
       "      <td>30</td>\n",
       "      <td>228</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>22</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>00158d00049b8ff3</td>\n",
       "      <td>1637557350000</td>\n",
       "      <td>2021-11-22 14:02:30</td>\n",
       "      <td>a2_sen_th_01</td>\n",
       "      <td>24c99ff6</td>\n",
       "      <td>reported</td>\n",
       "      <td>30</td>\n",
       "      <td>229</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>22</td>\n",
       "      <td>14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>00158d00049b8ff3</td>\n",
       "      <td>1637556749000</td>\n",
       "      <td>2021-11-22 13:52:29</td>\n",
       "      <td>a2_sen_th_01</td>\n",
       "      <td>413bb2a0</td>\n",
       "      <td>reported</td>\n",
       "      <td>30</td>\n",
       "      <td>228</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>22</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>00158d00049b8ff3</td>\n",
       "      <td>1637556147000</td>\n",
       "      <td>2021-11-22 13:42:27</td>\n",
       "      <td>a2_sen_th_01</td>\n",
       "      <td>6ea69ba3</td>\n",
       "      <td>reported</td>\n",
       "      <td>29</td>\n",
       "      <td>228</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>22</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>00158d00049b8ff3</td>\n",
       "      <td>1637555846000</td>\n",
       "      <td>2021-11-22 13:37:26</td>\n",
       "      <td>a2_sen_th_01</td>\n",
       "      <td>3f9e8043</td>\n",
       "      <td>reported</td>\n",
       "      <td>29</td>\n",
       "      <td>227</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>22</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>00158d00049b8ff3</td>\n",
       "      <td>1637554943000</td>\n",
       "      <td>2021-11-22 13:22:23</td>\n",
       "      <td>a2_sen_th_01</td>\n",
       "      <td>bb276dda</td>\n",
       "      <td>reported</td>\n",
       "      <td>29</td>\n",
       "      <td>226</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>22</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>00158d00049b8ff3</td>\n",
       "      <td>1637554642000</td>\n",
       "      <td>2021-11-22 13:17:22</td>\n",
       "      <td>a2_sen_th_01</td>\n",
       "      <td>14445641</td>\n",
       "      <td>reported</td>\n",
       "      <td>29</td>\n",
       "      <td>225</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>22</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>00158d00049b8ff3</td>\n",
       "      <td>1637553739000</td>\n",
       "      <td>2021-11-22 13:02:19</td>\n",
       "      <td>a2_sen_th_01</td>\n",
       "      <td>5ccc4310</td>\n",
       "      <td>reported</td>\n",
       "      <td>28</td>\n",
       "      <td>225</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>11</td>\n",
       "      <td>22</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          device_id             sk            timestamp         model  \\\n",
       "0  00158d00049b8ff3  1637558253000  2021-11-22 14:17:33  a2_sen_th_01   \n",
       "1  00158d00049b8ff3  1637557952000  2021-11-22 14:12:32  a2_sen_th_01   \n",
       "2  00158d00049b8ff3  1637557952000  2021-11-22 14:12:32  a2_sen_th_01   \n",
       "3  00158d00049b8ff3  1637557350000  2021-11-22 14:02:30  a2_sen_th_01   \n",
       "4  00158d00049b8ff3  1637556749000  2021-11-22 13:52:29  a2_sen_th_01   \n",
       "5  00158d00049b8ff3  1637556147000  2021-11-22 13:42:27  a2_sen_th_01   \n",
       "6  00158d00049b8ff3  1637555846000  2021-11-22 13:37:26  a2_sen_th_01   \n",
       "7  00158d00049b8ff3  1637554943000  2021-11-22 13:22:23  a2_sen_th_01   \n",
       "8  00158d00049b8ff3  1637554642000  2021-11-22 13:17:22  a2_sen_th_01   \n",
       "9  00158d00049b8ff3  1637553739000  2021-11-22 13:02:19  a2_sen_th_01   \n",
       "\n",
       "         id    e_type  hum  temp  battery  status  year month day hour  \n",
       "0  683fa131  reported   29   226        0       1  2021    11  22   14  \n",
       "1  2ac12530  reported   29   228        0       1  2021    11  22   14  \n",
       "2  42741e86  reported   30   228        0       1  2021    11  22   14  \n",
       "3  24c99ff6  reported   30   229        0       1  2021    11  22   14  \n",
       "4  413bb2a0  reported   30   228        0       1  2021    11  22   13  \n",
       "5  6ea69ba3  reported   29   228        0       1  2021    11  22   13  \n",
       "6  3f9e8043  reported   29   227        0       1  2021    11  22   13  \n",
       "7  bb276dda  reported   29   226        0       1  2021    11  22   13  \n",
       "8  14445641  reported   29   225        0       1  2021    11  22   13  \n",
       "9  5ccc4310  reported   28   225        0       1  2021    11  22   13  "
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = wr.athena.read_sql_query(\n",
    "    sql=\"SELECT * FROM temperature_humidity where device_id = '00158d0006c9d545' order by timestamp desc limit 10 /*연구소온습도센서*/;\",\n",
    "    database=\"ambt_b2c\"\n",
    ")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime(2021, 11, 30, 8, 8, 45)"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import datetime\n",
    "datetimeobj  = datetime.datetime.fromtimestamp(1638227325000/1000)\n",
    "datetimeobj"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "from datetime import datetime\n",
    "datetime.now().hour\n",
    "if datetime.now().weekday() < 5 :\n",
    "    if datetime.now().hour > 8 and datetime.now().hour < 17 :\n",
    "        print ('working time')        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = datetime(datetime.now().year, datetime.now().month, datetime.now().day, datetime.now().hour)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [],
   "source": [
    "b = datetime(int(df['year'][0]), int(df['month'][0]), int(df['day'][0]), int(df['hour'][0]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2021-11-25 13:00:00\n"
     ]
    }
   ],
   "source": [
    "print('{}'.format(b))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "not same\n"
     ]
    }
   ],
   "source": [
    "if a!=b:\n",
    "    print('not same')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'13'"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head(1)['hour'][0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2021'"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['year'][0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = datetime(datetime.now().year, datetime.now().month, datetime.now().day, datetime.now().hour)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [],
   "source": [
    "b = datetime(int(df['year'][0]), int(df['month'][0]), int(df['day'][0]), int(df['hour'][0]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "if a!=b:\n",
    "    print('same')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import awswrangler as wr\n",
    "df = wr.s3.read_parquet(\"s3://hdci-prototyping/motion_door/\", dataset=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<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>device_id</th>\n",
       "      <th>sk</th>\n",
       "      <th>timestamp</th>\n",
       "      <th>model</th>\n",
       "      <th>id</th>\n",
       "      <th>e_type</th>\n",
       "      <th>battery</th>\n",
       "      <th>status</th>\n",
       "      <th>evt</th>\n",
       "      <th>year</th>\n",
       "      <th>month</th>\n",
       "      <th>day</th>\n",
       "      <th>hour</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>00158d0005bb968a</td>\n",
       "      <td>1633822004000</td>\n",
       "      <td>2021-10-10 08:26:44</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>b087f0a8</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2021</td>\n",
       "      <td>10</td>\n",
       "      <td>10</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>00158d0002cab225</td>\n",
       "      <td>1634000451000</td>\n",
       "      <td>2021-10-12 10:00:51</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>c6a1edc2</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2021</td>\n",
       "      <td>10</td>\n",
       "      <td>12</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>00158d0002cab225</td>\n",
       "      <td>1634000825000</td>\n",
       "      <td>2021-10-12 10:07:05</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>7b442366</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>10</td>\n",
       "      <td>12</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>00158d0002cab225</td>\n",
       "      <td>1634000886000</td>\n",
       "      <td>2021-10-12 10:08:06</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>ab3c5929</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2021</td>\n",
       "      <td>10</td>\n",
       "      <td>12</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>00158d0002cab225</td>\n",
       "      <td>1634003953000</td>\n",
       "      <td>2021-10-12 10:59:13</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>0cdda406</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>10</td>\n",
       "      <td>12</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8269</th>\n",
       "      <td>00158d0006c9d665</td>\n",
       "      <td>1631145728000</td>\n",
       "      <td>2021-09-09 09:02:08</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>2a101ef0</td>\n",
       "      <td>reported</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2021</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8270</th>\n",
       "      <td>00158d0005bb968a</td>\n",
       "      <td>1631148819000</td>\n",
       "      <td>2021-09-09 09:53:39</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>2838e8cc</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8271</th>\n",
       "      <td>00158d0005bb96f3</td>\n",
       "      <td>1631148863000</td>\n",
       "      <td>2021-09-09 09:54:23</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>7af0ae63</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8272</th>\n",
       "      <td>00158d0006c9d665</td>\n",
       "      <td>1631148869000</td>\n",
       "      <td>2021-09-09 09:54:29</td>\n",
       "      <td>a2_sen_dor_01</td>\n",
       "      <td>3d8375e2</td>\n",
       "      <td>reported</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2021</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8273</th>\n",
       "      <td>00158d0002d545b4</td>\n",
       "      <td>1631149065000</td>\n",
       "      <td>2021-09-09 09:57:45</td>\n",
       "      <td>a2_sen_mt_01</td>\n",
       "      <td>99fb428f</td>\n",
       "      <td>reported</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2021</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>8274 rows × 13 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             device_id             sk            timestamp          model  \\\n",
       "0     00158d0005bb968a  1633822004000  2021-10-10 08:26:44  a2_sen_dor_01   \n",
       "1     00158d0002cab225  1634000451000  2021-10-12 10:00:51   a2_sen_mt_01   \n",
       "2     00158d0002cab225  1634000825000  2021-10-12 10:07:05   a2_sen_mt_01   \n",
       "3     00158d0002cab225  1634000886000  2021-10-12 10:08:06   a2_sen_mt_01   \n",
       "4     00158d0002cab225  1634003953000  2021-10-12 10:59:13   a2_sen_mt_01   \n",
       "...                ...            ...                  ...            ...   \n",
       "8269  00158d0006c9d665  1631145728000  2021-09-09 09:02:08  a2_sen_dor_01   \n",
       "8270  00158d0005bb968a  1631148819000  2021-09-09 09:53:39  a2_sen_dor_01   \n",
       "8271  00158d0005bb96f3  1631148863000  2021-09-09 09:54:23  a2_sen_dor_01   \n",
       "8272  00158d0006c9d665  1631148869000  2021-09-09 09:54:29  a2_sen_dor_01   \n",
       "8273  00158d0002d545b4  1631149065000  2021-09-09 09:57:45   a2_sen_mt_01   \n",
       "\n",
       "            id    e_type  battery  status  evt  year month day hour  \n",
       "0     b087f0a8  reported        0       1    0  2021    10  10    8  \n",
       "1     c6a1edc2  reported        0       1    0  2021    10  12   10  \n",
       "2     7b442366  reported        0       1    1  2021    10  12   10  \n",
       "3     ab3c5929  reported        0       1    0  2021    10  12   10  \n",
       "4     0cdda406  reported        0       1    1  2021    10  12   10  \n",
       "...        ...       ...      ...     ...  ...   ...   ...  ..  ...  \n",
       "8269  2a101ef0  reported        6       1    0  2021     9   9    9  \n",
       "8270  2838e8cc  reported        0       1    1  2021     9   9    9  \n",
       "8271  7af0ae63  reported        0       1    1  2021     9   9    9  \n",
       "8272  3d8375e2  reported        6       1    0  2021     9   9    9  \n",
       "8273  99fb428f  reported        0       1    1  2021     9   9    9  \n",
       "\n",
       "[8274 rows x 13 columns]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}