Skip to content

Instantly share code, notes, and snippets.

@den-run-ai
Created May 17, 2017 23:34
Show Gist options
  • Save den-run-ai/fd73a844f474847547eeb684572f2117 to your computer and use it in GitHub Desktop.
Save den-run-ai/fd73a844f474847547eeb684572f2117 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"INSTALLED VERSIONS\n",
"------------------\n",
"commit: None\n",
"python: 2.7.13.final.0\n",
"python-bits: 32\n",
"OS: Windows\n",
"OS-release: 7\n",
"machine: AMD64\n",
"processor: Intel64 Family 6 Model 60 Stepping 3, GenuineIntel\n",
"byteorder: little\n",
"LC_ALL: None\n",
"LANG: None\n",
"LOCALE: None.None\n",
"\n",
"pandas: 0.19.0\n",
"nose: 1.3.7\n",
"pip: 9.0.1\n",
"setuptools: 35.0.2\n",
"Cython: 0.25.2\n",
"numpy: 1.12.1\n",
"scipy: 0.19.0\n",
"statsmodels: 0.6.1\n",
"xarray: None\n",
"IPython: 5.3.0\n",
"sphinx: 1.4.8\n",
"patsy: 0.4.1\n",
"dateutil: 2.6.0\n",
"pytz: 2016.7\n",
"blosc: None\n",
"bottleneck: None\n",
"tables: 3.2.2\n",
"numexpr: 2.6.2\n",
"matplotlib: 2.0.0\n",
"openpyxl: 2.4.0\n",
"xlrd: 1.0.0\n",
"xlwt: 1.1.2\n",
"xlsxwriter: 0.9.3\n",
"lxml: 3.6.0\n",
"bs4: 4.5.1\n",
"html5lib: None\n",
"httplib2: 0.9.2\n",
"apiclient: 1.6.1\n",
"sqlalchemy: 1.1.3\n",
"pymysql: None\n",
"psycopg2: None\n",
"jinja2: 2.8\n",
"boto: 2.43.0\n",
"pandas_datareader: None\n"
]
}
],
"source": [
"pd.show_versions()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>0</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1900-01-31</th>\n",
" <td>12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-02-28</th>\n",
" <td>11</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-03-31</th>\n",
" <td>10</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-04-30</th>\n",
" <td>9</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-05-31</th>\n",
" <td>8</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-06-30</th>\n",
" <td>7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-07-31</th>\n",
" <td>6</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-08-31</th>\n",
" <td>5</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-09-30</th>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-10-31</th>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-11-30</th>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-12-31</th>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 0\n",
"1900-01-31 12\n",
"1900-02-28 11\n",
"1900-03-31 10\n",
"1900-04-30 9\n",
"1900-05-31 8\n",
"1900-06-30 7\n",
"1900-07-31 6\n",
"1900-08-31 5\n",
"1900-09-30 4\n",
"1900-10-31 3\n",
"1900-11-30 2\n",
"1900-12-31 1"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pdtest=pd.DataFrame(range(12,0,-1),index=pd.date_range(\"1900/01/01\",\"1900/12/31\",freq='M'))\n",
"pdtest"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>0</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1900-02-05</th>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-02-12</th>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-02-19</th>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-02-26</th>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-03-05</th>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-03-12</th>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-03-19</th>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-03-26</th>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-04-02</th>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-04-09</th>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-04-16</th>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-04-23</th>\n",
" <td>NaN</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-04-30</th>\n",
" <td>9.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-05-07</th>\n",
" <td>8.771429</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-05-14</th>\n",
" <td>8.542857</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-05-21</th>\n",
" <td>8.314286</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-05-28</th>\n",
" <td>8.085714</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-06-04</th>\n",
" <td>7.857143</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-06-11</th>\n",
" <td>7.628571</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-06-18</th>\n",
" <td>7.400000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-06-25</th>\n",
" <td>7.171429</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-07-02</th>\n",
" <td>6.942857</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-07-09</th>\n",
" <td>6.714286</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-07-16</th>\n",
" <td>6.485714</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-07-23</th>\n",
" <td>6.257143</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-07-30</th>\n",
" <td>6.028571</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-08-06</th>\n",
" <td>5.800000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-08-13</th>\n",
" <td>5.571429</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-08-20</th>\n",
" <td>5.342857</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-08-27</th>\n",
" <td>5.114286</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-09-03</th>\n",
" <td>4.885714</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-09-10</th>\n",
" <td>4.657143</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-09-17</th>\n",
" <td>4.428571</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-09-24</th>\n",
" <td>4.200000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-10-01</th>\n",
" <td>3.971429</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-10-08</th>\n",
" <td>3.742857</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-10-15</th>\n",
" <td>3.514286</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-10-22</th>\n",
" <td>3.285714</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-10-29</th>\n",
" <td>3.057143</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-11-05</th>\n",
" <td>2.828571</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-11-12</th>\n",
" <td>2.600000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-11-19</th>\n",
" <td>2.371429</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-11-26</th>\n",
" <td>2.142857</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-12-03</th>\n",
" <td>1.914286</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-12-10</th>\n",
" <td>1.685714</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-12-17</th>\n",
" <td>1.457143</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-12-24</th>\n",
" <td>1.228571</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1900-12-31</th>\n",
" <td>1.000000</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 0\n",
"1900-02-05 NaN\n",
"1900-02-12 NaN\n",
"1900-02-19 NaN\n",
"1900-02-26 NaN\n",
"1900-03-05 NaN\n",
"1900-03-12 NaN\n",
"1900-03-19 NaN\n",
"1900-03-26 NaN\n",
"1900-04-02 NaN\n",
"1900-04-09 NaN\n",
"1900-04-16 NaN\n",
"1900-04-23 NaN\n",
"1900-04-30 9.000000\n",
"1900-05-07 8.771429\n",
"1900-05-14 8.542857\n",
"1900-05-21 8.314286\n",
"1900-05-28 8.085714\n",
"1900-06-04 7.857143\n",
"1900-06-11 7.628571\n",
"1900-06-18 7.400000\n",
"1900-06-25 7.171429\n",
"1900-07-02 6.942857\n",
"1900-07-09 6.714286\n",
"1900-07-16 6.485714\n",
"1900-07-23 6.257143\n",
"1900-07-30 6.028571\n",
"1900-08-06 5.800000\n",
"1900-08-13 5.571429\n",
"1900-08-20 5.342857\n",
"1900-08-27 5.114286\n",
"1900-09-03 4.885714\n",
"1900-09-10 4.657143\n",
"1900-09-17 4.428571\n",
"1900-09-24 4.200000\n",
"1900-10-01 3.971429\n",
"1900-10-08 3.742857\n",
"1900-10-15 3.514286\n",
"1900-10-22 3.285714\n",
"1900-10-29 3.057143\n",
"1900-11-05 2.828571\n",
"1900-11-12 2.600000\n",
"1900-11-19 2.371429\n",
"1900-11-26 2.142857\n",
"1900-12-03 1.914286\n",
"1900-12-10 1.685714\n",
"1900-12-17 1.457143\n",
"1900-12-24 1.228571\n",
"1900-12-31 1.000000"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pdtest.resample('W-MON').interpolate()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.13"
},
"latex_envs": {
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 0
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment