{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "

Tutorial 0. Setup

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This first step to the tutorial will make sure your system is set up to do all the remaining sections, with all software installed and all data downloaded as needed. The [index](index.ipynb) covered background you might want before you start." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Getting set up\n", "\n", "Please consult [holoviz.org](http://holoviz.org/installation.html) for the full instructions on installing the software used in these tutorials. Here is the condensed version of those instructions, assuming you have already downloaded and installed [Anaconda](https://www.anaconda.com/download) or [Miniconda](https://conda.io/miniconda.html):" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "```\n", "conda create -n holoviz-tutorial python=3.7\n", "conda activate holoviz-tutorial\n", "conda install -c pyviz holoviz\n", "holoviz examples\n", "cd holoviz-examples\n", "jupyter notebook\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "See the full instructions at [holoviz.org](http://holoviz.org/installation.html) if you don't yet have conda, if you have an old version of conda, or if you are using JupyterLab.\n", "\n", "Once everything is installed, run the following cell to test the key imports needed for this tutorial. If it completes without errors your environment should be ready to go:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pandas as pd, datashader as ds, dask, bokeh, holoviews as hv # noqa\n", "from distutils.version import LooseVersion\n", "\n", "min_versions = dict(pd='0.24.0', ds='0.7.0', dask='1.2.0', bokeh='1.2.0', hv='1.12.3')\n", "\n", "for lib, ver in min_versions.items():\n", " v = globals()[lib].__version__\n", " if LooseVersion(v) < LooseVersion(ver):\n", " print(\"Error: expected {}={}, got {}\".format(lib,ver,v))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And you should see the HoloViews, Bokeh, and Matplotlib logos after running the following cell:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "hv.extension('bokeh', 'matplotlib')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Downloading sample data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Lastly, let's make sure the datasets needed are available. First, check that the large earthquake dataset was downloaded correctly during installation:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import os\n", "if not os.path.isfile('../data/earthquakes.parq'):\n", " print('Earthquakes dataset not found; please run \"holoviz fetch-data --path ..\".')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you don't have holoviz installed, for example if you created the environment from scratch, you can run:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from pyct import cmd\n", "if not os.path.isfile('../data/earthquakes.parq'):\n", " cmd.fetch_data(name='holoviz', path='..')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Make that you have the SNAPPY dependency required to read these data:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "try:\n", " import dask.dataframe as dd\n", " columns = ['depth', 'id', 'latitude', 'longitude', 'mag', 'place', 'time', 'type']\n", " data = dd.read_parquet('../data/earthquakes.parq', columns=columns, engine='fastparquet')\n", " data.head()\n", "except RuntimeError:\n", " print('SNAPPY is missing, so data cannot be read. If you are pip installing, '\n", " 'follow the steps here: https://github.com/andrix/python-snappy#dependencies')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you don't see any error messages above, you should be good to go! Now that you are set up, you can continue with the [rest of the tutorial sections](01_Overview.ipynb). You can also skip ahead to sections that speak to your interests more directly, such as the [Building Panels](Building_Panels.ipynb), [Working with Large Data](07_Large_Data.ipynb), or the various [real-world examples of using a variety of tools to solve a visualization problem](https://examples.pyviz.org).\n" ] } ], "metadata": { "language_info": { "name": "python", "pygments_lexer": "ipython3" } }, "nbformat": 4, "nbformat_minor": 4 }