{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Resample data\n", "> Marcos Duarte \n", "> [Laboratory of Biomechanics and Motor Control](http://demotu.org/) \n", "> Federal University of ABC, Brazil" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "%matplotlib notebook\n", "# tk qt notebook inline ipympl\n", "import matplotlib\n", "import matplotlib.pyplot as plt\n", "\n", "import sys, os\n", "sys.path.insert(1, r'./../functions')\n", "\n", "from resample import resample" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
012
0.001.203531-1.0260020.345930
0.010.7459630.944473-0.054512
0.020.789788-0.049776-1.072692
0.032.005024-1.013743-0.354158
0.04-1.185777-0.818023-1.550145
\n", "
" ], "text/plain": [ " 0 1 2\n", "0.00 1.203531 -1.026002 0.345930\n", "0.01 0.745963 0.944473 -0.054512\n", "0.02 0.789788 -0.049776 -1.072692\n", "0.03 2.005024 -1.013743 -0.354158\n", "0.04 -1.185777 -0.818023 -1.550145" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "y = np.random.randn(100, 3)\n", "freq_new = 100\n", "y = pd.DataFrame(data=y, columns=None)\n", "y.index = y.index/freq_new\n", "y.index.name = y.index.name\n", "y.head()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
012
0.0001.204336-1.0266880.346161
0.0011.298574-0.9258280.396714
0.0021.364617-0.7768930.436292
0.0031.398068-0.5865460.459980
0.0041.396121-0.3641840.463271
............
0.995-0.6725210.643513-0.066679
0.996-0.5414240.524998-0.065225
0.997-0.3997920.391877-0.055730
0.998-0.2567410.253914-0.040121
0.999-0.1209370.120501-0.020723
\n", "

1000 rows × 3 columns

\n", "
" ], "text/plain": [ " 0 1 2\n", "0.000 1.204336 -1.026688 0.346161\n", "0.001 1.298574 -0.925828 0.396714\n", "0.002 1.364617 -0.776893 0.436292\n", "0.003 1.398068 -0.586546 0.459980\n", "0.004 1.396121 -0.364184 0.463271\n", "... ... ... ...\n", "0.995 -0.672521 0.643513 -0.066679\n", "0.996 -0.541424 0.524998 -0.065225\n", "0.997 -0.399792 0.391877 -0.055730\n", "0.998 -0.256741 0.253914 -0.040121\n", "0.999 -0.120937 0.120501 -0.020723\n", "\n", "[1000 rows x 3 columns]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "y2 = resample(y, freq_old=100, freq_new=1000, limit=1000, method='resample_poly')\n", "y2" ] }, { "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.7.3" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "state": {}, "version_major": 2, "version_minor": 0 } } }, "nbformat": 4, "nbformat_minor": 4 }