<jupyter_start><jupyter_text>NYC Taxi data using dask_cudf  Import cuxfilter<jupyter_code>from cuxfilter import charts
import cuxfilter
from bokeh import palettes
from cuxfilter.layouts import feature_and_double_base

import cudf, dask_cudf

from dask.distributed import Client, wait
from dask_cuda import LocalCUDACluster

cluster = LocalCUDACluster()
client = Client(cluster)
client
#update data_dir if you have downloaded datasets elsewhere
DATA_DIR = './data'<jupyter_output><empty_output><jupyter_text>Download required datasets<jupyter_code>from cuxfilter.sampledata import datasets_check
datasets_check('nyc_taxi', base_dir=DATA_DIR)<jupyter_output><empty_output><jupyter_text>preprocess the data<jupyter_code>cudf_df = cudf.read_csv(DATA_DIR + '/nyc_taxi.csv')

from pyproj import Proj, Transformer

# Apply transformation
transform_4326_to_3857 = Transformer.from_crs('epsg:4326', 'epsg:3857')
cudf_df['dropoff_x'], cudf_df['dropoff_y'] = transform_4326_to_3857.transform(
                                                cudf_df['dropoff_latitude'].to_array(), cudf_df['dropoff_longitude'].to_array()
                                            )

cudf_df = cudf_df.drop(['dropoff_latitude', 'dropoff_longitude'], axis=1)
cudf_df = cudf_df.dropna(axis=0)

# Filter over Manhattan
cudf_df = cudf_df[
    (cudf_df.dropoff_x > -8239910.23) & (cudf_df.dropoff_x < -8229529.24) & (cudf_df.dropoff_y > 4968481.34) & (cudf_df.dropoff_y < 4983152.92)
]

cudf_df.tpep_pickup_datetime = cudf.to_datetime(cudf_df.tpep_pickup_datetime, format="%Y-%m-%d")
cudf_df.tpep_dropoff_datetime = cudf.to_datetime(cudf_df.tpep_dropoff_datetime, format="%Y-%m-%d")
cudf_df.head()<jupyter_output><empty_output><jupyter_text>Convert cudf df to dask_cudf df<jupyter_code>cudf_df = dask_cudf.from_cudf(cudf_df, npartitions=2).persist()<jupyter_output><empty_output><jupyter_text>Read the dataset<jupyter_code>cux_df = cuxfilter.DataFrame.from_dataframe(cudf_df)<jupyter_output><empty_output><jupyter_text>Define charts<jupyter_code>from bokeh.tile_providers import get_provider as gp
tile_provider = gp('CARTODBPOSITRON')<jupyter_output><empty_output><jupyter_text>Uncomment the below lines and replace MAPBOX_TOKEN with mapbox token string if you want to use mapbox map-tiles. Can be created for free here -https://www.mapbox.com/help/define-access-token/<jupyter_code>#from cuxfilter.assets.custom_tiles import get_provider, Vendors
#tile_provider = get_provider(Vendors.MAPBOX_LIGHT, access_token=MAPBOX_TOKEN)
chart1 = charts.scatter(x='dropoff_x',
                         y='dropoff_y',
                         aggregate_fn='mean',aggregate_col='payment_type', pixel_shade_type='log', legend_position='center',
                         tile_provider=tile_provider, x_range=(-8239910.23,-8229529.24), y_range=(4968481.34,4983152.92))

chart2 = charts.bar('passenger_count', data_points=9)
chart3 = cuxfilter.charts.bar('tpep_pickup_datetime')
chart4 = cuxfilter.charts.date_range_slider('tpep_dropoff_datetime')<jupyter_output><empty_output><jupyter_text>Create a dashboard object<jupyter_code>d = cux_df.dashboard([chart1, chart2, chart3, chart4], layout=feature_and_double_base, theme=cuxfilter.themes.rapids, title= 'NYC TAXI DATASET')
d.show()
#dashboard object
d<jupyter_output><empty_output><jupyter_text>Starting the dashboard 1. d.show('current_notebook_url:current_notebook_port') remote dashboard2. d.app('current_notebook_url:current_notebook_port') inline in notebook (layout is ignored, and charts are displayed one below another)Incase you need to stop the server:- d.stop()<jupyter_code># preview 
await d.preview()<jupyter_output><empty_output><jupyter_text>Export the queried data into a dataframe<jupyter_code>queried_df = d.export()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10586362430352879, 'fraction_numerical': 0.029185460334306183, 'mean_word_length': 6.36328125, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 43, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '376904', 'license': 'Apache-2.0', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1401, 'n_words': 218, 'path': 'docs/source/examples/NYC_taxi_example.ipynb', 'repo_name': 'Ethyling/cuxfilter', 'size': '3769'}