<jupyter_start><jupyter_text>NYC Taxi data  Import cuxfilter<jupyter_code>import cuxfilter
from bokeh import palettes
from cuxfilter.layouts import double_feature

import cudf
#update data_dir if you have downloaded datasets elsewhere
DATA_DIR = './data'<jupyter_output><empty_output><jupyter_text>Download required datasets<jupyter_code>! curl https://rapidsai-data.s3.us-east-2.amazonaws.com/viz-data/nyc_taxi.tar.gz --create-dirs -o $DATA_DIR/nyc_taxi.tar.gz
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.head()<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 = cuxfilter.charts.scatter_geo(x='dropoff_x',
                                         y='dropoff_y',
                                         aggregate_fn='count',
                                         tile_provider=tile_provider, x_range=(-8239910.23,-8229529.24), y_range=(4968481.34,4983152.92))

chart2 = cuxfilter.charts.bar('passenger_count', data_points=9)<jupyter_output><empty_output><jupyter_text>Create a dashboard object<jupyter_code>d = cux_df.dashboard([chart1, chart2], layout=double_feature, theme=cuxfilter.themes.dark, title= 'NYC TAXI DATASET')
#dashboard object
d
#execute below line for dashboard preview
#await d.preview()<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># d.show(notebook_url='')<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.10739709068399876, 'fraction_numerical': 0.03311668214175178, 'mean_word_length': 5.144486692015209, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 40, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '177640', 'license': 'Apache-2.0', 'n_tokens_mistral': 1221, 'n_tokens_neox': 1158, 'n_words': 188, 'path': 'notebooks/NYC_taxi_example.ipynb', 'repo_name': 'sean-frye/cuxfilter', 'size': '3231'}