Skip to content
Permalink
Browse files

Adding first items in reference gallery - depends on branch of fsspec

  • Loading branch information...
jsignell committed Sep 11, 2019
1 parent bd31588 commit df38169f8ee898917b6d8797eef483d355801d24
@@ -22,3 +22,20 @@ sources:
kind: line
y: ['Robbery', 'Burglary']
x: 'Year'

stocks:
driver: csv
args:
urlpath:
- 'wfcached://sampledata.bokeh.org/AAPL.csv'
- 'wfcached://sampledata.bokeh.org/FB.csv'
- 'wfcached://sampledata.bokeh.org/GOOG.csv'
- 'wfcached://sampledata.bokeh.org/IBM.csv'
- 'wfcached://sampledata.bokeh.org/MSFT.csv'
path_as_pattern: 'sampledata.bokeh.org/{ticker}.csv'
csv_kwargs:
blocksize: null
parse_dates: ['Date']
storage_options:
target_protocol: http
cache_storage: '{{ CATALOG_DIR }}/data/cache'
@@ -0,0 +1,65 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import intake\n",
"import hvplot.pandas\n",
"import pandas as pd\n",
"\n",
"from hvplot.sample_data import stocks"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"df = stocks.read()\n",
"df.tail()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df[df.ticker == 'MSFT'].hvplot.area(x='Date', y=['Open', 'Close'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df.hvplot.area(x='Date', y='Close', by='ticker', stacked=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"table = df.groupby(['ticker', df.Date.dt.year])[['High', 'Low']].agg({'High': max, 'Low': min})\n",
"table.hvplot.area(x='Date', y='Low', y2='High', groupby='ticker')"
]
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
@@ -0,0 +1,61 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import intake\n",
"import hvplot.pandas\n",
"import pandas as pd\n",
"\n",
"from hvplot.sample_data import stocks"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df = stocks.read()\n",
"table = df.groupby([df.Date.dt.year, 'ticker'])['Volume'].mean()\n",
"table"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"table.hvplot.bar(stacked=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"table.hvplot.bar('Date', 'Volume', by='ticker', stacked=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
@@ -0,0 +1,68 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import xarray as xr\n",
"import hvplot.xarray\n",
"\n",
"ds = xr.tutorial.open_dataset('air_temperature')\n",
"ds"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ds.hvplot.contour(geo=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ds.mean(dim='time').hvplot.contour(z='air', x='lon', y='lat', levels=20, \n",
" clabel='T [K]', label='Mean Air temperature [K]',\n",
" cmap='gray')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Geographic Data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ds.hvplot.contour(levels=20, geo=True, line_width=2, cmap='reds', tiles='EsriImagery')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
@@ -0,0 +1,61 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import xarray as xr\n",
"import hvplot.xarray\n",
"\n",
"ds = xr.tutorial.open_dataset('air_temperature')\n",
"ds"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ds.hvplot.contourf()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ds.mean(dim='time').hvplot.contourf(z='air', x='lon', y='lat', levels=20,\n",
" clabel='T [K]', label='Mean Air temperature [K]',\n",
" cmap='fire')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Geographic Data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ds.hvplot.contourf(levels=20, geo=True, coastline=True)"
]
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
@@ -0,0 +1,94 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import xarray as xr\n",
"import hvplot.xarray\n",
"\n",
"ds = xr.tutorial.open_dataset('air_temperature')\n",
"ds"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ds.hvplot.image()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This is equivalent to writing:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ds.hvplot.image(x='lon', y='lat', z='air', groupby='time', cmap='fire')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A simpler case would be to take the temperature at just one day. Here we'll show how to use `clim` and `clabel` to control the colorbar."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"time = '2014-01-01'\n",
"data = ds.sel(time=time).mean('time') - 273 \n",
"\n",
"data.hvplot.image(x='lon', y='lat', z='air', \n",
" label=time, clabel='T [C]', \n",
" cmap='coolwarm', clim=(-40, 40))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Geographic Data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ds.hvplot.image(geo=True, coastline=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

0 comments on commit df38169

Please sign in to comment.
You can’t perform that action at this time.