{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Examples**"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" P | \n",
"
\n",
" \n",
" \n",
" \n",
" 2019-04-09 00:00:00 | \n",
" 2 | \n",
"
\n",
" \n",
" 2019-04-10 00:20:00 | \n",
" 3 | \n",
"
\n",
" \n",
" 2019-04-11 00:40:00 | \n",
" 4 | \n",
"
\n",
" \n",
" 2019-04-12 01:00:00 | \n",
" 5 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" P\n",
"2019-04-09 00:00:00 2\n",
"2019-04-10 00:20:00 3\n",
"2019-04-11 00:40:00 4\n",
"2019-04-12 01:00:00 5"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"i = pd.date_range('2019-04-09', periods=4, freq='1D20min')\n",
"ts = pd.DataFrame({'P': [2, 3, 4, 5]}, index=i)\n",
"ts"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
""
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" P | \n",
"
\n",
" \n",
" \n",
" \n",
" 2019-04-10 00:20:00 | \n",
" 3 | \n",
"
\n",
" \n",
" 2019-04-11 00:40:00 | \n",
" 4 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" P\n",
"2019-04-10 00:20:00 3\n",
"2019-04-11 00:40:00 4"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ts.between_time('0:15', '0:45')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You get the times that are not between two times by setting start_time later than end_time:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" P | \n",
"
\n",
" \n",
" \n",
" \n",
" 2019-04-09 00:00:00 | \n",
" 2 | \n",
"
\n",
" \n",
" 2019-04-12 01:00:00 | \n",
" 5 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" P\n",
"2019-04-09 00:00:00 2\n",
"2019-04-12 01:00:00 5"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ts.between_time('0:45', '0:15')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}