{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 10 minutes to cuxfilter" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This is a short introduction to the cuxfilter.py library, mostly going over the basic usage and features provided as a quick summary." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### What is cuxfilter?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "cuxfilter is inspired from the Crossfilter library, which is a fast, browser-based filtering mechanism across multiple dimensions and offers features do groupby operations on top of the dimensions. One of the major limitations of using Crossfilter is that it keeps data in-memory on a client-side browser, making it inefficient for processing large datasets.\n", "\n", "cuxfilter solves the issues by leveraging the power of the rapids.ai stack, mainly cudf. The data is maintained in a gpu as a GPU DataFrame and operations like groupby aggregations, sorting and querying are done on the gpu itself, only returning the result as the output to the charts.\n", "\n", "cuxfilter acts as a `connector` library, which provides the connections between different visualization libraries and a GPU dataframe without much hassle. This also allows the user to use charts from different libraries in a single dashboard, while also providing the interaction." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### The modules" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "> cuxfilter has following usable modules" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "1. cuxfilter.DataFrame\n", "2. cuxfilter.DashBoard\n", "3. cuxfilter.charts\n", "4. cuxfilter.layouts\n", "5. cuxfilter.themes" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Usage" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 1. Import the required modules" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "tags": [] }, "outputs": [], "source": [ "import cuxfilter\n", "from cuxfilter import DataFrame, themes, layouts" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Download required datasets" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "tags": [] }, "outputs": [], "source": [ "#update data_dir if you have downloaded datasets elsewhere\n", "DATA_DIR = './data/'\n", "\n", "! curl https://data.rapids.ai/viz-data/auto_accidents.arrow.gz --create-dirs -o $DATA_DIR/auto_accidents.arrow.gz" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Dataset - ./data//auto_accidents.arrow\n", "\n", "dataset already downloaded\n" ] } ], "source": [ "from cuxfilter.sampledata import datasets_check\n", "datasets_check('auto_accidents', base_dir=DATA_DIR)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 2. Read some data\n", "\n", "> cuxfilter can read arrow files off disk, or an inmemory cudf dataframe" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "
\n", " | dropoff_x | \n", "dropoff_y | \n", "DAY_WEEK | \n", "DAY_WEEK_STR | \n", "YEAR | \n", "MONTH | \n", "
---|---|---|---|---|---|---|
__index_level_0__ | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
0 | \n", "-9.685585e+06 | \n", "3.939943e+06 | \n", "1 | \n", "Sunday | \n", "2017 | \n", "2 | \n", "
1 | \n", "-9.661068e+06 | \n", "4.117979e+06 | \n", "3 | \n", "Tuesday | \n", "2017 | \n", "2 | \n", "
2 | \n", "-9.589649e+06 | \n", "3.811519e+06 | \n", "3 | \n", "Tuesday | \n", "2017 | \n", "1 | \n", "
3 | \n", "-9.589649e+06 | \n", "3.811519e+06 | \n", "3 | \n", "Tuesday | \n", "2017 | \n", "1 | \n", "
4 | \n", "-9.589649e+06 | \n", "3.811519e+06 | \n", "3 | \n", "Tuesday | \n", "2017 | \n", "1 | \n", "