You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
543 lines
66 KiB
543 lines
66 KiB
2 years ago
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"___\n",
|
||
|
"\n",
|
||
|
"<a href='http://www.pieriandata.com'><img src='../Pierian_Data_Logo.png'/></a>\n",
|
||
|
"___\n",
|
||
|
"<center><em>Copyright Pierian Data</em></center>\n",
|
||
|
"<center><em>For more information, visit us at <a href='http://www.pieriandata.com'>www.pieriandata.com</a></em></center>"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Time Resampling\n",
|
||
|
"\n",
|
||
|
"Let's learn how to sample time series data! This will be useful later on in the course!"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {
|
||
|
"collapsed": true
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import pandas as pd\n",
|
||
|
"%matplotlib inline"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Import the data\n",
|
||
|
"For this exercise we'll look at Starbucks stock data from 2015 to 2018 which includes daily closing prices and trading volumes."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"metadata": {
|
||
|
"collapsed": true
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"df = pd.read_csv('../Data/starbucks.csv', index_col='Date', parse_dates=True)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Note: the above code is a faster way of doing the following:\n",
|
||
|
"<pre>df = pd.read_csv('../Data/starbucks.csv')\n",
|
||
|
"df['Date'] = pd.to_datetime(df['Date'])\n",
|
||
|
"df.set_index('Date',inplace=True)</pre>"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"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>Close</th>\n",
|
||
|
" <th>Volume</th>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>Date</th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2015-01-02</th>\n",
|
||
|
" <td>38.0061</td>\n",
|
||
|
" <td>6906098</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2015-01-05</th>\n",
|
||
|
" <td>37.2781</td>\n",
|
||
|
" <td>11623796</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2015-01-06</th>\n",
|
||
|
" <td>36.9748</td>\n",
|
||
|
" <td>7664340</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2015-01-07</th>\n",
|
||
|
" <td>37.8848</td>\n",
|
||
|
" <td>9732554</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2015-01-08</th>\n",
|
||
|
" <td>38.4961</td>\n",
|
||
|
" <td>13170548</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" Close Volume\n",
|
||
|
"Date \n",
|
||
|
"2015-01-02 38.0061 6906098\n",
|
||
|
"2015-01-05 37.2781 11623796\n",
|
||
|
"2015-01-06 36.9748 7664340\n",
|
||
|
"2015-01-07 37.8848 9732554\n",
|
||
|
"2015-01-08 38.4961 13170548"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 3,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"df.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## resample()\n",
|
||
|
"\n",
|
||
|
"A common operation with time series data is resampling based on the time series index. Let's see how to use the resample() method. [[reference](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.resample.html)]"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"DatetimeIndex(['2015-01-02', '2015-01-05', '2015-01-06', '2015-01-07',\n",
|
||
|
" '2015-01-08', '2015-01-09', '2015-01-12', '2015-01-13',\n",
|
||
|
" '2015-01-14', '2015-01-15',\n",
|
||
|
" ...\n",
|
||
|
" '2018-12-17', '2018-12-18', '2018-12-19', '2018-12-20',\n",
|
||
|
" '2018-12-21', '2018-12-24', '2018-12-26', '2018-12-27',\n",
|
||
|
" '2018-12-28', '2018-12-31'],\n",
|
||
|
" dtype='datetime64[ns]', name='Date', length=1006, freq=None)"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 4,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# Our index\n",
|
||
|
"df.index"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"When calling `.resample()` you first need to pass in a **rule** parameter, then you need to call some sort of aggregation function.\n",
|
||
|
"\n",
|
||
|
"The **rule** parameter describes the frequency with which to apply the aggregation function (daily, monthly, yearly, etc.)<br>\n",
|
||
|
"It is passed in using an \"offset alias\" - refer to the table below. [[reference](http://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases)]\n",
|
||
|
"\n",
|
||
|
"The aggregation function is needed because, due to resampling, we need some sort of mathematical rule to join the rows (mean, sum, count, etc.)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"<table style=\"display: inline-block\">\n",
|
||
|
" <caption style=\"text-align: center\"><strong>TIME SERIES OFFSET ALIASES</strong></caption>\n",
|
||
|
"<tr><th>ALIAS</th><th>DESCRIPTION</th></tr>\n",
|
||
|
"<tr><td>B</td><td>business day frequency</td></tr>\n",
|
||
|
"<tr><td>C</td><td>custom business day frequency (experimental)</td></tr>\n",
|
||
|
"<tr><td>D</td><td>calendar day frequency</td></tr>\n",
|
||
|
"<tr><td>W</td><td>weekly frequency</td></tr>\n",
|
||
|
"<tr><td>M</td><td>month end frequency</td></tr>\n",
|
||
|
"<tr><td>SM</td><td>semi-month end frequency (15th and end of month)</td></tr>\n",
|
||
|
"<tr><td>BM</td><td>business month end frequency</td></tr>\n",
|
||
|
"<tr><td>CBM</td><td>custom business month end frequency</td></tr>\n",
|
||
|
"<tr><td>MS</td><td>month start frequency</td></tr>\n",
|
||
|
"<tr><td>SMS</td><td>semi-month start frequency (1st and 15th)</td></tr>\n",
|
||
|
"<tr><td>BMS</td><td>business month start frequency</td></tr>\n",
|
||
|
"<tr><td>CBMS</td><td>custom business month start frequency</td></tr>\n",
|
||
|
"<tr><td>Q</td><td>quarter end frequency</td></tr>\n",
|
||
|
"<tr><td></td><td><font color=white>intentionally left blank</font></td></tr></table>\n",
|
||
|
"\n",
|
||
|
"<table style=\"display: inline-block; margin-left: 40px\">\n",
|
||
|
"<caption style=\"text-align: center\"></caption>\n",
|
||
|
"<tr><th>ALIAS</th><th>DESCRIPTION</th></tr>\n",
|
||
|
"<tr><td>BQ</td><td>business quarter endfrequency</td></tr>\n",
|
||
|
"<tr><td>QS</td><td>quarter start frequency</td></tr>\n",
|
||
|
"<tr><td>BQS</td><td>business quarter start frequency</td></tr>\n",
|
||
|
"<tr><td>A</td><td>year end frequency</td></tr>\n",
|
||
|
"<tr><td>BA</td><td>business year end frequency</td></tr>\n",
|
||
|
"<tr><td>AS</td><td>year start frequency</td></tr>\n",
|
||
|
"<tr><td>BAS</td><td>business year start frequency</td></tr>\n",
|
||
|
"<tr><td>BH</td><td>business hour frequency</td></tr>\n",
|
||
|
"<tr><td>H</td><td>hourly frequency</td></tr>\n",
|
||
|
"<tr><td>T, min</td><td>minutely frequency</td></tr>\n",
|
||
|
"<tr><td>S</td><td>secondly frequency</td></tr>\n",
|
||
|
"<tr><td>L, ms</td><td>milliseconds</td></tr>\n",
|
||
|
"<tr><td>U, us</td><td>microseconds</td></tr>\n",
|
||
|
"<tr><td>N</td><td>nanoseconds</td></tr></table>"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"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>Close</th>\n",
|
||
|
" <th>Volume</th>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>Date</th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2015-12-31</th>\n",
|
||
|
" <td>50.078100</td>\n",
|
||
|
" <td>8.649190e+06</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2016-12-31</th>\n",
|
||
|
" <td>53.891732</td>\n",
|
||
|
" <td>9.300633e+06</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2017-12-31</th>\n",
|
||
|
" <td>55.457310</td>\n",
|
||
|
" <td>9.296078e+06</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2018-12-31</th>\n",
|
||
|
" <td>56.870005</td>\n",
|
||
|
" <td>1.122883e+07</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" Close Volume\n",
|
||
|
"Date \n",
|
||
|
"2015-12-31 50.078100 8.649190e+06\n",
|
||
|
"2016-12-31 53.891732 9.300633e+06\n",
|
||
|
"2017-12-31 55.457310 9.296078e+06\n",
|
||
|
"2018-12-31 56.870005 1.122883e+07"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 5,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# Yearly Means\n",
|
||
|
"df.resample(rule='A').mean()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Resampling rule 'A' takes all of the data points in a given year, applies the aggregation function (in this case we calculate the mean), and reports the result as the last day of that year."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Custom Resampling Functions\n",
|
||
|
"\n",
|
||
|
"We're not limited to pandas built-in summary functions (min/max/mean etc.). We can define our own function:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 6,
|
||
|
"metadata": {
|
||
|
"collapsed": true
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def first_day(entry):\n",
|
||
|
" \"\"\"\n",
|
||
|
" Returns the first instance of the period, regardless of sampling rate.\n",
|
||
|
" \"\"\"\n",
|
||
|
" if len(entry): # handles the case of missing data\n",
|
||
|
" return entry[0]"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 7,
|
||
|
"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>Close</th>\n",
|
||
|
" <th>Volume</th>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>Date</th>\n",
|
||
|
" <th></th>\n",
|
||
|
" <th></th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2015-12-31</th>\n",
|
||
|
" <td>38.0061</td>\n",
|
||
|
" <td>6906098</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2016-12-31</th>\n",
|
||
|
" <td>55.0780</td>\n",
|
||
|
" <td>13521544</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2017-12-31</th>\n",
|
||
|
" <td>53.1100</td>\n",
|
||
|
" <td>7809307</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2018-12-31</th>\n",
|
||
|
" <td>56.3243</td>\n",
|
||
|
" <td>7215978</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" Close Volume\n",
|
||
|
"Date \n",
|
||
|
"2015-12-31 38.0061 6906098\n",
|
||
|
"2016-12-31 55.0780 13521544\n",
|
||
|
"2017-12-31 53.1100 7809307\n",
|
||
|
"2018-12-31 56.3243 7215978"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 7,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"df.resample(rule='A').apply(first_day)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"### Plotting"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 8,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw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11cF/XUk1lfIdqrvoqFv9F8D6qg7J/ppouOZ8lR6nLut3Lgc8DF1E9fxtQHRfp1FNUgXgP1fGZnjn5n6btPwC2VnU21QURcVt6DDek+9scuL6D+7mW6pTIJ6kOZL4nIhambZ9Jt/MU1S/VV37BR8R9VK+DT6fr3gS8ofWG01TOEVQHhy+iOqA+5NdHN9OS01v2aibp81Rn1hxedy0lkfQGqsBYMSJerrses8HyCL1LSBpHdcDqtLprKUGaclgh9fUk4GKHuXU7B3oXkPRh4EGq0OmKz/HoAkdRTenMoXoj1lH1lmM2dJ5yMTMrhEfoZmaFGNEP0FlrrbVi8uTJI3mXZmZdb9asWY9HxPj+9hvRQJ88eTIzZ84cybs0M+t6kh7ofy9PuZiZFcOBbmZWCAe6mVkhHOhmZoVwoJuZFcKBbmZWCAe6mVkhHOhmZoVwoJuZFWJE3ylqZjZYszffou4SOrLFnbNru2+P0M3MCuFANzMrhAPdzKwQDnQzs0L4oKjZMHnD9Df0v9OrwO1Tb6+7BMvEI3Qzs0I40M3MCuFANzMrhAPdzKwQPihqix0/tu4KOnP803VXYPaq5BG6mVkhHOhmZoVwoJuZFcKBbmZWCAe6mVkhHOhmZoVwoJuZFcKBbmZWCAe6mVkhHOhmZoVwoJuZFaKjz3KRdD/wLPASsCgipkhaE/gpMBm4HzgoIhYOT5lmZtafgYzQd46IbSJiSlo+FrgyIjYBrkzLZmZWk6F82uJ+wE7p8nTgauDTQ6xnwCYfe9lI3+Wg3H/S3nWXYGaF63SEHsCvJM2SNC2tmxA
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"df['Close'].resample('A').mean().plot.bar(title='Yearly Mean Closing Price for Starbucks');"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Pandas treats each sample as its own trace, and by default assigns different colors to each one. If you want, you can pass a <strong>color</strong> argument to assign your own color collection, or to set a uniform color. For example, <tt>color='#1f77b4'</tt> sets a uniform \"steel blue\" color.\n",
|
||
|
"\n",
|
||
|
"Also, the above code can be broken into two lines for improved readability."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 9,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAF1CAYAAAD4PxH2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3XmYXGWZ/vHvTcImCVsIYQsEZZURUCMyMsqOCAygsskIYX5gXMBlcEYZ1BncEJfL7VLAjEGCKBEQJICDIhJckCWsigGCbAmBECBhFceQ5/fHeRsqRXe6uvN2H+o99+e6+kqdc2p56qnK3W+/59QpRQRmZtb9Vqq7ADMzy8OBbmZWCAe6mVkhHOhmZoVwoJuZFcKBbmZWCAf6K5SkcyWdUncdw0HSXpLuX8H72E3SHZlKWiGSvi/p5Mz3KUnnSFos6dqc9z1UJB0naeYQ3G9j/m8MlAO9Q5J+JOmstnW7Snpc0oZ11dUuhWNIOr9t/cS0/lc11bWzpCskPSnpCUnXSzo61/1HxMyI2C7X/bWS9DtJz0t6RtJCSRdK2mA5tRwXEadmLmM3YFdgo4h4S447lDRZ0l2Snpb0iKTLJK2Rtjk0u5ADvXMfAfaTtDeApNWA/wE+HhEP53wgSSNW8C4WALtKWrtl3dHA3St4v4Mi6Z+AXwFXAa8GxgAnAPvVUc8gfSAiRgHbAGOBr/V2pQyvXV82A+6LiOcGekNJI3tZtyfwWeCwiBgNbAdcuMJV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A+Q6CZWaXTEXoAv5R0k6TJad24iHgYIP27fm83lDRZ0ixJsxYuXLjiFZuZWa86HaHvEhH
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"title = 'Yearly Mean Closing Price for Starbucks'\n",
|
||
|
"df['Close'].resample('A').mean().plot.bar(title=title,color=['#1f77b4']);"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 10,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA6IAAAHiCAYAAADyP3HCAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzs3Xm8rXVZ+P3PJQccUObDJOCxJIeekoyQsnIAVNAEezS0FEh6sEyz7Emx/JX+TEWtxAY0EvWoxWBqoKCAOKS/R5AZ1AMeByaZjgihmSJwPX/c381ZbPaw7r2/+17fs/i8X6/92ntN17que32/a93XvocVmYkkSZIkSUN5wKQTkCRJkiTdv9iISpIkSZIGZSMqSZIkSRqUjagkSZIkaVA2opIkSZKkQdmISpIkSZIGZSMqSfdDEZER8ah5bjsiIr44dE4rJSKuioj9lxnjqxHxlEopLSePX4uIK1cg7nMj4tqI+EFE/ELt+CthoTG8jJhPiYjrasaUJM3NRlSSJqg0SXdExA6zrr+krGivqfAcn4uI31tunDGfKyPipohYNXLdqoi4OSJW5IurI2KriDg2Iq4pjdQ3yuUdFn/0eDLzZzPzc7XizShN/10l79vL6/7sBfL4QmY+unYewN8AL8/Mh2bmx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jagkSZIkaVCDHiO6ww475Jo1a4Z8SkmSJEnSQC688MLvZubqxe43aCO6Zs0aLrhgvq/IkyRJkiRtyiLi6nHu5665kiRJkqRB2YhKkiRJkga1aCMaEY+OiEtGfm6PiD+OiO0i4uyIWF9+bztEwpIkSZKkTduijWh
|
||
|
"text/plain": [
|
||
|
"<Figure size 1152x432 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"title = 'Monthly Max Closing Price for Starbucks'\n",
|
||
|
"df['Close'].resample('M').max().plot.bar(figsize=(16,6), title=title,color='#1f77b4');"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"That is it! Up next we'll learn about time shifts!"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"anaconda-cloud": {},
|
||
|
"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.6"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 1
|
||
|
}
|