From 7f0e5dfc9c3cc81c754e5a408acbf8897bbbb28a Mon Sep 17 00:00:00 2001 From: Manfred Cheung Date: Mon, 8 Dec 2025 15:12:11 -0500 Subject: [PATCH 1/7] add auto_graph_renderer_switching option to KeplerConfig --- graphistry/kepler.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/graphistry/kepler.py b/graphistry/kepler.py index 0329563962..b0bca59e58 100644 --- a/graphistry/kepler.py +++ b/graphistry/kepler.py @@ -526,6 +526,8 @@ class KeplerConfig: :type overlay_blending: Optional[Literal['normal', 'additive', 'subtractive']] :param tile_style: Base map tile style configuration :type tile_style: Optional[Dict[str, Any]] + :param auto_graph_renderer_switching: Enable automatic graph renderer switching + :type auto_graph_renderer_switching: Optional[bool] **Example: Structured parameters** :: @@ -576,7 +578,8 @@ def __init__( *, cull_unused_columns: Optional[bool] = None, overlay_blending: Optional[Literal['normal', 'additive', 'subtractive']] = None, - tile_style: Optional[Dict[str, Any]] = None + tile_style: Optional[Dict[str, Any]] = None, + auto_graph_renderer_switching: Optional[bool] = None ) -> None: ... @@ -762,7 +765,8 @@ def with_config( *, cull_unused_columns: Optional[bool] = None, overlay_blending: Optional[Literal['normal', 'additive', 'subtractive']] = None, - tile_style: Optional[Dict[str, Any]] = None + tile_style: Optional[Dict[str, Any]] = None, + auto_graph_renderer_switching: Optional[bool] = None ) -> 'KeplerEncoding': ... @@ -777,6 +781,8 @@ def with_config(self, config: Optional[KeplerConfig] = None, **kwargs) -> 'Keple :type overlay_blending: Optional[Literal['normal', 'additive', 'subtractive']] :param tile_style: Base map tile style configuration :type tile_style: Optional[Dict[str, Any]] + :param auto_graph_renderer_switching: Enable automatic graph renderer switching + :type auto_graph_renderer_switching: Optional[bool] :return: New KeplerEncoding instance with updated config :rtype: KeplerEncoding """ From 4a6f499a23f145fd95911e351bdab53ad0effc25 Mon Sep 17 00:00:00 2001 From: Manfred Cheung Date: Mon, 8 Dec 2025 15:23:36 -0500 Subject: [PATCH 2/7] add ten_mins_to_gfql demo notebook --- demos/gfql/ten_mins_to_gfql.ipynb | 2376 +++++++++++++++++++++++++++++ 1 file changed, 2376 insertions(+) create mode 100644 demos/gfql/ten_mins_to_gfql.ipynb diff --git a/demos/gfql/ten_mins_to_gfql.ipynb b/demos/gfql/ten_mins_to_gfql.ipynb new file mode 100644 index 0000000000..f999dc76f7 --- /dev/null +++ b/demos/gfql/ten_mins_to_gfql.ipynb @@ -0,0 +1,2376 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 10 mins to GFQL: ICIJ FinCEN Files Visualization\n", + "\n", + "This notebook demonstrates GFQL (Graph Query Language) using the ICIJ FinCEN Files dataset.\n", + "\n", + "Based on: https://hub.graphistry.com/docs/GFQL/gfql/" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Setup and Registration\n", + "\n", + "First, import Graphistry and register with your credentials." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import graphistry\n", + "\n", + "# graphistry.register(api=3, protocol=\"https\", server=\"hub.graphistry.com\",\n", + "# username=\"...\", password=\"...\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Download and Load Data\n", + "\n", + "Download the ICIJ FinCEN Files dataset and create a graph." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "import requests\n", + "import zipfile\n", + "import pandas as pd\n", + "\n", + "# download data\n", + "resp = requests.get(\"https://media.icij.org/uploads/2020/09/download_data_fincen_files.zip\")\n", + "with open(\"download_data_fincen_files.zip\", \"wb\") as f:\n", + " f.write(resp.content)\n", + "with zipfile.ZipFile(\"download_data_fincen_files.zip\",\"r\") as zip_ref:\n", + " zip_ref.extract(\"download_transactions_map.csv\")\n", + "\n", + "# read csv into pandas dataframe and change type of time columns in data to datetime\n", + "df_e = pd.read_csv(\"download_transactions_map.csv\")\n", + "df_e[\"begin_date\"] = pd.to_datetime(df_e[\"begin_date\"])\n", + "df_e[\"end_date\"] = pd.to_datetime(df_e[\"end_date\"])\n", + "\n", + "# create graph\n", + "g = graphistry.edges(df_e, \"originator_bank_id\", \"beneficiary_bank_id\").materialize_nodes()\n", + "\n", + "# rename id col in nodes to nodeId\n", + "df_n = g._nodes.rename(columns={'id': 'nodeId'})\n", + "g = g.nodes(df_n, 'nodeId')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Node-list sample\n", + "\n", + "View a sample of the nodes in the graph." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.microsoft.datawrangler.viewer.v0+json": { + "columns": [ + { + "name": "index", + "rawType": "int64", + "type": "integer" + }, + { + "name": "nodeId", + "rawType": "object", + "type": "string" + } + ], + "ref": "05cea886-7891-4730-a624-01b6cfe3ca46", + "rows": [ + [ + "0", + "cimb-bank-berhad" + ], + [ + "1", + "barclays-bank-plc-ho-uk" + ], + [ + "2", + "natwest-offshore" + ], + [ + "3", + "evrofinance-mosnarbank" + ], + [ + "4", + "latvian-trade-commercial-bank" + ] + ], + "shape": { + "columns": 1, + "rows": 5 + } + }, + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
nodeId
0cimb-bank-berhad
1barclays-bank-plc-ho-uk
2natwest-offshore
3evrofinance-mosnarbank
4latvian-trade-commercial-bank
\n", + "
" + ], + "text/plain": [ + " nodeId\n", + "0 cimb-bank-berhad\n", + "1 barclays-bank-plc-ho-uk\n", + "2 natwest-offshore\n", + "3 evrofinance-mosnarbank\n", + "4 latvian-trade-commercial-bank" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g._nodes.head()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Edge-list sample\n", + "\n", + "View a sample of the edges in the graph." + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.microsoft.datawrangler.viewer.v0+json": { + "columns": [ + { + "name": "index", + "rawType": "int64", + "type": "integer" + }, + { + "name": "id", + "rawType": "int64", + "type": "integer" + }, + { + "name": "icij_sar_id", + "rawType": "int64", + "type": "integer" + }, + { + "name": "filer_org_name_id", + "rawType": "object", + "type": "string" + }, + { + "name": "filer_org_name", + "rawType": "object", + "type": "string" + }, + { + "name": "begin_date", + "rawType": "datetime64[ns]", + "type": "datetime" + }, + { + "name": "end_date", + "rawType": "datetime64[ns]", + "type": "datetime" + }, + { + "name": "originator_bank_id", + "rawType": "object", + "type": "string" + }, + { + "name": "originator_bank", + "rawType": "object", + "type": "string" + }, + { + "name": "originator_bank_country", + "rawType": "object", + "type": "string" + }, + { + "name": "originator_iso", + "rawType": "object", + "type": "string" + }, + { + "name": "beneficiary_bank_id", + "rawType": "object", + "type": "string" + }, + { + "name": "beneficiary_bank", + "rawType": "object", + "type": "string" + }, + { + "name": "beneficiary_bank_country", + "rawType": "object", + "type": "string" + }, + { + "name": "beneficiary_iso", + "rawType": "object", + "type": "string" + }, + { + "name": "number_transactions", + "rawType": "float64", + "type": "float" + }, + { + "name": "amount_transactions", + "rawType": "float64", + "type": "float" + } + ], + "ref": "151add92-8624-459e-bab4-e27523b2edcb", + "rows": [ + [ + "0", + "223254", + "3297", + "the-bank-of-new-york-mellon-corp", + "The Bank of New York Mellon Corp.", + "2015-03-25 00:00:00", + "2015-09-25 00:00:00", + "cimb-bank-berhad", + "CIMB Bank Berhad", + "Singapore", + "SGP", + "barclays-bank-plc-london-england-gbr", + "Barclays Bank Plc", + "United Kingdom", + "GBR", + "68.0", + "56898523.47" + ], + [ + "1", + "223255", + "3297", + "the-bank-of-new-york-mellon-corp", + "The Bank of New York Mellon Corp.", + "2015-03-30 00:00:00", + "2015-09-25 00:00:00", + "cimb-bank-berhad", + "CIMB Bank Berhad", + "Singapore", + "SGP", + "barclays-bank-plc-london-england-gbr", + "Barclays Bank Plc", + "United Kingdom", + "GBR", + "118.0", + "116238361.25" + ], + [ + "2", + "223258", + "2924", + "the-bank-of-new-york-mellon-corp", + "The Bank of New York Mellon Corp.", + "2012-07-05 00:00:00", + "2012-07-05 00:00:00", + "barclays-bank-plc-ho-uk", + "Barclays Bank Plc Ho UK", + "United Kingdom", + "GBR", + "skandinaviska-enskilda-banken-stockholm-sweden-swe", + "Skandinaviska Enskilda Banken", + "Sweden", + "SWE", + null, + "5000.0" + ], + [ + "3", + "223259", + "2924", + "the-bank-of-new-york-mellon-corp", + "The Bank of New York Mellon Corp.", + "2012-06-20 00:00:00", + "2012-06-20 00:00:00", + "barclays-bank-plc-ho-uk", + "Barclays Bank Plc Ho UK", + "United Kingdom", + "GBR", + "skandinaviska-enskilda-banken-stockholm-sweden-swe", + "Skandinaviska Enskilda Banken", + "Sweden", + "SWE", + null, + "9990.0" + ], + [ + "4", + "223260", + "2924", + "the-bank-of-new-york-mellon-corp", + "The Bank of New York Mellon Corp.", + "2012-05-31 00:00:00", + "2012-05-31 00:00:00", + "barclays-bank-plc-ho-uk", + "Barclays Bank Plc Ho UK", + "United Kingdom", + "GBR", + "skandinaviska-enskilda-banken-stockholm-sweden-swe", + "Skandinaviska Enskilda Banken", + "Sweden", + "SWE", + null, + "12000.0" + ] + ], + "shape": { + "columns": 16, + "rows": 5 + } + }, + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idicij_sar_idfiler_org_name_idfiler_org_namebegin_dateend_dateoriginator_bank_idoriginator_bankoriginator_bank_countryoriginator_isobeneficiary_bank_idbeneficiary_bankbeneficiary_bank_countrybeneficiary_isonumber_transactionsamount_transactions
02232543297the-bank-of-new-york-mellon-corpThe Bank of New York Mellon Corp.2015-03-252015-09-25cimb-bank-berhadCIMB Bank BerhadSingaporeSGPbarclays-bank-plc-london-england-gbrBarclays Bank PlcUnited KingdomGBR68.05.689852e+07
12232553297the-bank-of-new-york-mellon-corpThe Bank of New York Mellon Corp.2015-03-302015-09-25cimb-bank-berhadCIMB Bank BerhadSingaporeSGPbarclays-bank-plc-london-england-gbrBarclays Bank PlcUnited KingdomGBR118.01.162384e+08
22232582924the-bank-of-new-york-mellon-corpThe Bank of New York Mellon Corp.2012-07-052012-07-05barclays-bank-plc-ho-ukBarclays Bank Plc Ho UKUnited KingdomGBRskandinaviska-enskilda-banken-stockholm-sweden...Skandinaviska Enskilda BankenSwedenSWENaN5.000000e+03
32232592924the-bank-of-new-york-mellon-corpThe Bank of New York Mellon Corp.2012-06-202012-06-20barclays-bank-plc-ho-ukBarclays Bank Plc Ho UKUnited KingdomGBRskandinaviska-enskilda-banken-stockholm-sweden...Skandinaviska Enskilda BankenSwedenSWENaN9.990000e+03
42232602924the-bank-of-new-york-mellon-corpThe Bank of New York Mellon Corp.2012-05-312012-05-31barclays-bank-plc-ho-ukBarclays Bank Plc Ho UKUnited KingdomGBRskandinaviska-enskilda-banken-stockholm-sweden...Skandinaviska Enskilda BankenSwedenSWENaN1.200000e+04
\n", + "
" + ], + "text/plain": [ + " id icij_sar_id filer_org_name_id \\\n", + "0 223254 3297 the-bank-of-new-york-mellon-corp \n", + "1 223255 3297 the-bank-of-new-york-mellon-corp \n", + "2 223258 2924 the-bank-of-new-york-mellon-corp \n", + "3 223259 2924 the-bank-of-new-york-mellon-corp \n", + "4 223260 2924 the-bank-of-new-york-mellon-corp \n", + "\n", + " filer_org_name begin_date end_date \\\n", + "0 The Bank of New York Mellon Corp. 2015-03-25 2015-09-25 \n", + "1 The Bank of New York Mellon Corp. 2015-03-30 2015-09-25 \n", + "2 The Bank of New York Mellon Corp. 2012-07-05 2012-07-05 \n", + "3 The Bank of New York Mellon Corp. 2012-06-20 2012-06-20 \n", + "4 The Bank of New York Mellon Corp. 2012-05-31 2012-05-31 \n", + "\n", + " originator_bank_id originator_bank originator_bank_country \\\n", + "0 cimb-bank-berhad CIMB Bank Berhad Singapore \n", + "1 cimb-bank-berhad CIMB Bank Berhad Singapore \n", + "2 barclays-bank-plc-ho-uk Barclays Bank Plc Ho UK United Kingdom \n", + "3 barclays-bank-plc-ho-uk Barclays Bank Plc Ho UK United Kingdom \n", + "4 barclays-bank-plc-ho-uk Barclays Bank Plc Ho UK United Kingdom \n", + "\n", + " originator_iso beneficiary_bank_id \\\n", + "0 SGP barclays-bank-plc-london-england-gbr \n", + "1 SGP barclays-bank-plc-london-england-gbr \n", + "2 GBR skandinaviska-enskilda-banken-stockholm-sweden... \n", + "3 GBR skandinaviska-enskilda-banken-stockholm-sweden... \n", + "4 GBR skandinaviska-enskilda-banken-stockholm-sweden... \n", + "\n", + " beneficiary_bank beneficiary_bank_country beneficiary_iso \\\n", + "0 Barclays Bank Plc United Kingdom GBR \n", + "1 Barclays Bank Plc United Kingdom GBR \n", + "2 Skandinaviska Enskilda Banken Sweden SWE \n", + "3 Skandinaviska Enskilda Banken Sweden SWE \n", + "4 Skandinaviska Enskilda Banken Sweden SWE \n", + "\n", + " number_transactions amount_transactions \n", + "0 68.0 5.689852e+07 \n", + "1 118.0 1.162384e+08 \n", + "2 NaN 5.000000e+03 \n", + "3 NaN 9.990000e+03 \n", + "4 NaN 1.200000e+04 " + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g._edges.head()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Visualization Setup\n", + "\n", + "Create a color palette for visualizing the graph." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "def nonlinear_palette_generator(v, linear_palette):\n", + " out = []\n", + " num_palette = len(linear_palette)\n", + " num_palette_repetitions = [round(n**v) + 1 for n in range(num_palette)]\n", + " if v < 1:\n", + " num_palette_repetitions.reverse()\n", + " for i, color in enumerate(linear_palette):\n", + " out = out + [color for _ in range(num_palette_repetitions[i])]\n", + " return out\n", + "\n", + "palette = [\"#46327e\", \"#365c8d\", \"#277f8e\", \"#1fa187\", \"#4ac16d\", \"#a0da39\", \"#fde724\"]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Visualize full graph with encodings." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# render graph of entire dataset\n", + "g_out = g.bind(edge_label=\"amount_transactions\")\n", + "g_out = g_out.encode_edge_color(\"amount_transactions\",\n", + " nonlinear_palette_generator(1.2, palette),\n", + " as_continuous=True)\n", + "g_out = g_out.settings(\n", + " height=800,\n", + " url_params={\n", + " \"pointOpacity\": 0.6 if len(g_out._nodes) > 1500 else 0.9,\n", + " \"edgeOpacity\": 0.3 if len(g_out._edges) > 1500 else 0.9,\n", + " \"play\": 2000})\n", + "g_out.plot()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Caribbean havens subgraph\n", + "\n", + "Find transactions involving Caribbean tax havens using GFQL chain operations." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [], + "source": [ + "from graphistry.compute.predicates.is_in import is_in\n", + "from graphistry.compute.ast import n, e_forward\n", + "\n", + "carib_havens = [\"British Virgin Islands\", \"Cayman Islands\", \"Bahamas\"]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Outgoing transactions from Caribbean havens" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "chain_operations = graphistry.Chain([\n", + " n(name=\"is_carib_bank_origin\"),\n", + " e_forward(hops=1, edge_match={\"originator_bank_country\": is_in(options=carib_havens)}),\n", + "])\n", + "g_carib_out = g.gfql(chain_operations)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.microsoft.datawrangler.viewer.v0+json": { + "columns": [ + { + "name": "index", + "rawType": "int64", + "type": "integer" + }, + { + "name": "id", + "rawType": "int64", + "type": "integer" + }, + { + "name": "icij_sar_id", + "rawType": "int64", + "type": "integer" + }, + { + "name": "filer_org_name_id", + "rawType": "object", + "type": "string" + }, + { + "name": "filer_org_name", + "rawType": "object", + "type": "string" + }, + { + "name": "begin_date", + "rawType": "datetime64[ns]", + "type": "datetime" + }, + { + "name": "end_date", + "rawType": "datetime64[ns]", + "type": "datetime" + }, + { + "name": "originator_bank_id", + "rawType": "object", + "type": "string" + }, + { + "name": "originator_bank", + "rawType": "object", + "type": "string" + }, + { + "name": "originator_bank_country", + "rawType": "object", + "type": "string" + }, + { + "name": "originator_iso", + "rawType": "object", + "type": "string" + }, + { + "name": "beneficiary_bank_id", + "rawType": "object", + "type": "string" + }, + { + "name": "beneficiary_bank", + "rawType": "object", + "type": "string" + }, + { + "name": "beneficiary_bank_country", + "rawType": "object", + "type": "string" + }, + { + "name": "beneficiary_iso", + "rawType": "object", + "type": "string" + }, + { + "name": "number_transactions", + "rawType": "float64", + "type": "float" + }, + { + "name": "amount_transactions", + "rawType": "float64", + "type": "float" + } + ], + "ref": "3d0c1eb2-30b6-4fcf-9e01-d80815aaef18", + "rows": [ + [ + "0", + "225260", + "3213", + "the-bank-of-new-york-mellon-corp", + "The Bank of New York Mellon Corp.", + "2013-07-18 00:00:00", + "2013-07-23 00:00:00", + "caledonian-bank-limited", + "Caledonian Bank Limited", + "Cayman Islands", + "CYM", + "merrill-lynch-new-york-ny-usa", + "Merrill Lynch", + "United States", + "USA", + "2.0", + "985000.0" + ], + [ + "1", + "225261", + "3213", + "the-bank-of-new-york-mellon-corp", + "The Bank of New York Mellon Corp.", + "2013-08-16 00:00:00", + "2013-08-16 00:00:00", + "caledonian-bank-limited", + "Caledonian Bank Limited", + "Cayman Islands", + "CYM", + "t-bank-julius-baer-and-co-ag-zurich-switzerland-che", + "T Bank Julius Baer And Co. AG", + "Switzerland", + "CHE", + "1.0", + "500000.0" + ], + [ + "2", + "225262", + "3213", + "the-bank-of-new-york-mellon-corp", + "The Bank of New York Mellon Corp.", + "2013-08-28 00:00:00", + "2013-09-05 00:00:00", + "caledonian-bank-limited", + "Caledonian Bank Limited", + "Cayman Islands", + "CYM", + "barclays-capital-inc-new-york-usa-usa", + "Barclays Capital Inc", + "United States", + "USA", + "2.0", + "450000.0" + ], + [ + "3", + "225264", + "3213", + "the-bank-of-new-york-mellon-corp", + "The Bank of New York Mellon Corp.", + "2013-03-21 00:00:00", + "2013-07-31 00:00:00", + "gonet-bank-and-trust-limited", + "Gonet Bank And Trust Limited", + "Bahamas", + "BHS", + "caledonian-bank-limited-georgetown-cayman-islands-cym", + "Caledonian Bank Limited", + "Cayman Islands", + "CYM", + "2.0", + "400000.0" + ], + [ + "4", + "225883", + "4076", + "the-northern-trust-company", + "The Northern Trust Company", + "2015-02-04 00:00:00", + "2015-02-04 00:00:00", + "dms-bank-trust-ltd", + "DMS Bank & Trust Ltd", + "Cayman Islands", + "CYM", + "hsbc-hong-kong-hkg", + "HSBC", + "Hong Kong", + "HKG", + "1.0", + "101000.0" + ] + ], + "shape": { + "columns": 16, + "rows": 5 + } + }, + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idicij_sar_idfiler_org_name_idfiler_org_namebegin_dateend_dateoriginator_bank_idoriginator_bankoriginator_bank_countryoriginator_isobeneficiary_bank_idbeneficiary_bankbeneficiary_bank_countrybeneficiary_isonumber_transactionsamount_transactions
02252603213the-bank-of-new-york-mellon-corpThe Bank of New York Mellon Corp.2013-07-182013-07-23caledonian-bank-limitedCaledonian Bank LimitedCayman IslandsCYMmerrill-lynch-new-york-ny-usaMerrill LynchUnited StatesUSA2.0985000.0
12252613213the-bank-of-new-york-mellon-corpThe Bank of New York Mellon Corp.2013-08-162013-08-16caledonian-bank-limitedCaledonian Bank LimitedCayman IslandsCYMt-bank-julius-baer-and-co-ag-zurich-switzerlan...T Bank Julius Baer And Co. AGSwitzerlandCHE1.0500000.0
22252623213the-bank-of-new-york-mellon-corpThe Bank of New York Mellon Corp.2013-08-282013-09-05caledonian-bank-limitedCaledonian Bank LimitedCayman IslandsCYMbarclays-capital-inc-new-york-usa-usaBarclays Capital IncUnited StatesUSA2.0450000.0
32252643213the-bank-of-new-york-mellon-corpThe Bank of New York Mellon Corp.2013-03-212013-07-31gonet-bank-and-trust-limitedGonet Bank And Trust LimitedBahamasBHScaledonian-bank-limited-georgetown-cayman-isla...Caledonian Bank LimitedCayman IslandsCYM2.0400000.0
42258834076the-northern-trust-companyThe Northern Trust Company2015-02-042015-02-04dms-bank-trust-ltdDMS Bank & Trust LtdCayman IslandsCYMhsbc-hong-kong-hkgHSBCHong KongHKG1.0101000.0
\n", + "
" + ], + "text/plain": [ + " id icij_sar_id filer_org_name_id \\\n", + "0 225260 3213 the-bank-of-new-york-mellon-corp \n", + "1 225261 3213 the-bank-of-new-york-mellon-corp \n", + "2 225262 3213 the-bank-of-new-york-mellon-corp \n", + "3 225264 3213 the-bank-of-new-york-mellon-corp \n", + "4 225883 4076 the-northern-trust-company \n", + "\n", + " filer_org_name begin_date end_date \\\n", + "0 The Bank of New York Mellon Corp. 2013-07-18 2013-07-23 \n", + "1 The Bank of New York Mellon Corp. 2013-08-16 2013-08-16 \n", + "2 The Bank of New York Mellon Corp. 2013-08-28 2013-09-05 \n", + "3 The Bank of New York Mellon Corp. 2013-03-21 2013-07-31 \n", + "4 The Northern Trust Company 2015-02-04 2015-02-04 \n", + "\n", + " originator_bank_id originator_bank \\\n", + "0 caledonian-bank-limited Caledonian Bank Limited \n", + "1 caledonian-bank-limited Caledonian Bank Limited \n", + "2 caledonian-bank-limited Caledonian Bank Limited \n", + "3 gonet-bank-and-trust-limited Gonet Bank And Trust Limited \n", + "4 dms-bank-trust-ltd DMS Bank & Trust Ltd \n", + "\n", + " originator_bank_country originator_iso \\\n", + "0 Cayman Islands CYM \n", + "1 Cayman Islands CYM \n", + "2 Cayman Islands CYM \n", + "3 Bahamas BHS \n", + "4 Cayman Islands CYM \n", + "\n", + " beneficiary_bank_id \\\n", + "0 merrill-lynch-new-york-ny-usa \n", + "1 t-bank-julius-baer-and-co-ag-zurich-switzerlan... \n", + "2 barclays-capital-inc-new-york-usa-usa \n", + "3 caledonian-bank-limited-georgetown-cayman-isla... \n", + "4 hsbc-hong-kong-hkg \n", + "\n", + " beneficiary_bank beneficiary_bank_country beneficiary_iso \\\n", + "0 Merrill Lynch United States USA \n", + "1 T Bank Julius Baer And Co. AG Switzerland CHE \n", + "2 Barclays Capital Inc United States USA \n", + "3 Caledonian Bank Limited Cayman Islands CYM \n", + "4 HSBC Hong Kong HKG \n", + "\n", + " number_transactions amount_transactions \n", + "0 2.0 985000.0 \n", + "1 1.0 500000.0 \n", + "2 2.0 450000.0 \n", + "3 2.0 400000.0 \n", + "4 1.0 101000.0 " + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g_carib_out._edges.head()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Incoming transactions to Caribbean havens" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [], + "source": [ + "chain_operations = graphistry.Chain([\n", + " e_forward(hops=1, edge_match={\"beneficiary_bank_country\": is_in(options=carib_havens)}),\n", + " n(name=\"is_carib_bank_destination\")\n", + "])\n", + "g_carib_in = g.gfql(chain_operations)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.microsoft.datawrangler.viewer.v0+json": { + "columns": [ + { + "name": "index", + "rawType": "int64", + "type": "integer" + }, + { + "name": "id", + "rawType": "int64", + "type": "integer" + }, + { + "name": "icij_sar_id", + "rawType": "int64", + "type": "integer" + }, + { + "name": "filer_org_name_id", + "rawType": "object", + "type": "string" + }, + { + "name": "filer_org_name", + "rawType": "object", + "type": "string" + }, + { + "name": "begin_date", + "rawType": "datetime64[ns]", + "type": "datetime" + }, + { + "name": "end_date", + "rawType": "datetime64[ns]", + "type": "datetime" + }, + { + "name": "originator_bank_id", + "rawType": "object", + "type": "string" + }, + { + "name": "originator_bank", + "rawType": "object", + "type": "string" + }, + { + "name": "originator_bank_country", + "rawType": "object", + "type": "string" + }, + { + "name": "originator_iso", + "rawType": "object", + "type": "string" + }, + { + "name": "beneficiary_bank_id", + "rawType": "object", + "type": "string" + }, + { + "name": "beneficiary_bank", + "rawType": "object", + "type": "string" + }, + { + "name": "beneficiary_bank_country", + "rawType": "object", + "type": "string" + }, + { + "name": "beneficiary_iso", + "rawType": "object", + "type": "string" + }, + { + "name": "number_transactions", + "rawType": "float64", + "type": "float" + }, + { + "name": "amount_transactions", + "rawType": "float64", + "type": "float" + } + ], + "ref": "b3969747-31f4-4f2f-b61d-251512cd32c0", + "rows": [ + [ + "0", + "225255", + "3213", + "the-bank-of-new-york-mellon-corp", + "The Bank of New York Mellon Corp.", + "2013-08-27 00:00:00", + "2013-08-27 00:00:00", + "pictet-and-cie", + "Pictet And Cie", + "Switzerland", + "CHE", + "caledonian-bank-limited-georgetown-cayman-islands-cym", + "Caledonian Bank Limited", + "Cayman Islands", + "CYM", + "1.0", + "300015.0" + ], + [ + "1", + "225256", + "3213", + "the-bank-of-new-york-mellon-corp", + "The Bank of New York Mellon Corp.", + "2013-08-16 00:00:00", + "2013-08-16 00:00:00", + "banco-de-santander-sa", + "Banco De Santander S.A.", + "Uruguay", + "URY", + "caledonian-bank-limited-georgetown-cayman-islands-cym", + "Caledonian Bank Limited", + "Cayman Islands", + "CYM", + "1.0", + "200000.0" + ], + [ + "2", + "225257", + "3213", + "the-bank-of-new-york-mellon-corp", + "The Bank of New York Mellon Corp.", + "2013-08-01 00:00:00", + "2013-09-06 00:00:00", + "jpmorgan-chase-bank-na", + "JPMorgan Chase Bank Na", + "United States", + "USA", + "caledonian-bank-limited-georgetown-cayman-islands-cym", + "Caledonian Bank Limited", + "Cayman Islands", + "CYM", + "3.0", + "388000.0" + ], + [ + "3", + "225263", + "3213", + "the-bank-of-new-york-mellon-corp", + "The Bank of New York Mellon Corp.", + "2013-07-24 00:00:00", + "2013-07-25 00:00:00", + "emirates-nbd-bank-pjsc", + "Emirates Nbd Bank PJSC", + "United Arab Emirates", + "ARE", + "caledonian-bank-limited-georgetown-cayman-islands-cym", + "Caledonian Bank Limited", + "Cayman Islands", + "CYM", + "2.0", + "200000.0" + ], + [ + "4", + "225264", + "3213", + "the-bank-of-new-york-mellon-corp", + "The Bank of New York Mellon Corp.", + "2013-03-21 00:00:00", + "2013-07-31 00:00:00", + "gonet-bank-and-trust-limited", + "Gonet Bank And Trust Limited", + "Bahamas", + "BHS", + "caledonian-bank-limited-georgetown-cayman-islands-cym", + "Caledonian Bank Limited", + "Cayman Islands", + "CYM", + "2.0", + "400000.0" + ] + ], + "shape": { + "columns": 16, + "rows": 5 + } + }, + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idicij_sar_idfiler_org_name_idfiler_org_namebegin_dateend_dateoriginator_bank_idoriginator_bankoriginator_bank_countryoriginator_isobeneficiary_bank_idbeneficiary_bankbeneficiary_bank_countrybeneficiary_isonumber_transactionsamount_transactions
02252553213the-bank-of-new-york-mellon-corpThe Bank of New York Mellon Corp.2013-08-272013-08-27pictet-and-ciePictet And CieSwitzerlandCHEcaledonian-bank-limited-georgetown-cayman-isla...Caledonian Bank LimitedCayman IslandsCYM1.0300015.0
12252563213the-bank-of-new-york-mellon-corpThe Bank of New York Mellon Corp.2013-08-162013-08-16banco-de-santander-saBanco De Santander S.A.UruguayURYcaledonian-bank-limited-georgetown-cayman-isla...Caledonian Bank LimitedCayman IslandsCYM1.0200000.0
22252573213the-bank-of-new-york-mellon-corpThe Bank of New York Mellon Corp.2013-08-012013-09-06jpmorgan-chase-bank-naJPMorgan Chase Bank NaUnited StatesUSAcaledonian-bank-limited-georgetown-cayman-isla...Caledonian Bank LimitedCayman IslandsCYM3.0388000.0
32252633213the-bank-of-new-york-mellon-corpThe Bank of New York Mellon Corp.2013-07-242013-07-25emirates-nbd-bank-pjscEmirates Nbd Bank PJSCUnited Arab EmiratesAREcaledonian-bank-limited-georgetown-cayman-isla...Caledonian Bank LimitedCayman IslandsCYM2.0200000.0
42252643213the-bank-of-new-york-mellon-corpThe Bank of New York Mellon Corp.2013-03-212013-07-31gonet-bank-and-trust-limitedGonet Bank And Trust LimitedBahamasBHScaledonian-bank-limited-georgetown-cayman-isla...Caledonian Bank LimitedCayman IslandsCYM2.0400000.0
\n", + "
" + ], + "text/plain": [ + " id icij_sar_id filer_org_name_id \\\n", + "0 225255 3213 the-bank-of-new-york-mellon-corp \n", + "1 225256 3213 the-bank-of-new-york-mellon-corp \n", + "2 225257 3213 the-bank-of-new-york-mellon-corp \n", + "3 225263 3213 the-bank-of-new-york-mellon-corp \n", + "4 225264 3213 the-bank-of-new-york-mellon-corp \n", + "\n", + " filer_org_name begin_date end_date \\\n", + "0 The Bank of New York Mellon Corp. 2013-08-27 2013-08-27 \n", + "1 The Bank of New York Mellon Corp. 2013-08-16 2013-08-16 \n", + "2 The Bank of New York Mellon Corp. 2013-08-01 2013-09-06 \n", + "3 The Bank of New York Mellon Corp. 2013-07-24 2013-07-25 \n", + "4 The Bank of New York Mellon Corp. 2013-03-21 2013-07-31 \n", + "\n", + " originator_bank_id originator_bank \\\n", + "0 pictet-and-cie Pictet And Cie \n", + "1 banco-de-santander-sa Banco De Santander S.A. \n", + "2 jpmorgan-chase-bank-na JPMorgan Chase Bank Na \n", + "3 emirates-nbd-bank-pjsc Emirates Nbd Bank PJSC \n", + "4 gonet-bank-and-trust-limited Gonet Bank And Trust Limited \n", + "\n", + " originator_bank_country originator_iso \\\n", + "0 Switzerland CHE \n", + "1 Uruguay URY \n", + "2 United States USA \n", + "3 United Arab Emirates ARE \n", + "4 Bahamas BHS \n", + "\n", + " beneficiary_bank_id beneficiary_bank \\\n", + "0 caledonian-bank-limited-georgetown-cayman-isla... Caledonian Bank Limited \n", + "1 caledonian-bank-limited-georgetown-cayman-isla... Caledonian Bank Limited \n", + "2 caledonian-bank-limited-georgetown-cayman-isla... Caledonian Bank Limited \n", + "3 caledonian-bank-limited-georgetown-cayman-isla... Caledonian Bank Limited \n", + "4 caledonian-bank-limited-georgetown-cayman-isla... Caledonian Bank Limited \n", + "\n", + " beneficiary_bank_country beneficiary_iso number_transactions \\\n", + "0 Cayman Islands CYM 1.0 \n", + "1 Cayman Islands CYM 1.0 \n", + "2 Cayman Islands CYM 3.0 \n", + "3 Cayman Islands CYM 2.0 \n", + "4 Cayman Islands CYM 2.0 \n", + "\n", + " amount_transactions \n", + "0 300015.0 \n", + "1 200000.0 \n", + "2 388000.0 \n", + "3 200000.0 \n", + "4 400000.0 " + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g_carib_in._edges.head()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Visualize Caribbean transactions\n", + "\n", + "Encode the visualization with colors based on transaction amounts." + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g_carib = graphistry.edges(pd.concat([g_carib_in._edges, g_carib_out._edges], ignore_index=True), \n", + " \"originator_bank_id\", \"beneficiary_bank_id\").materialize_nodes()\n", + "\n", + "g_carib_styled = (\n", + " g_carib\n", + " .encode_edge_color('amount_transactions',\n", + " palette=nonlinear_palette_generator(1.05, palette),\n", + " as_continuous=True)\n", + " .settings(url_params={'play': 2000})\n", + ")\n", + "\n", + "# Uncomment to plot\n", + "g_carib_styled.plot()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Single transaction subgraph\n", + "\n", + "Find a specific transaction pattern: Latvia to Russia transactions in a specific amount range." + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [], + "source": [ + "from graphistry import contains\n", + "\n", + "chain_operations = graphistry.Chain([\n", + " e_forward(hops=1, edge_match={\"originator_bank_country\": \"Latvia\", \"beneficiary_bank_country\": \"Russia\"}),\n", + " n({\"nodeId\": contains(pat=\"\")}, name=\"is_rus_beneficiary\"),\n", + "])\n", + "g_lva_rus = g.gfql(chain_operations)" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.microsoft.datawrangler.viewer.v0+json": { + "columns": [ + { + "name": "index", + "rawType": "int64", + "type": "integer" + }, + { + "name": "id", + "rawType": "int64", + "type": "integer" + }, + { + "name": "icij_sar_id", + "rawType": "int64", + "type": "integer" + }, + { + "name": "filer_org_name_id", + "rawType": "object", + "type": "string" + }, + { + "name": "filer_org_name", + "rawType": "object", + "type": "string" + }, + { + "name": "begin_date", + "rawType": "datetime64[ns]", + "type": "datetime" + }, + { + "name": "end_date", + "rawType": "datetime64[ns]", + "type": "datetime" + }, + { + "name": "originator_bank_id", + "rawType": "object", + "type": "string" + }, + { + "name": "originator_bank", + "rawType": "object", + "type": "string" + }, + { + "name": "originator_bank_country", + "rawType": "object", + "type": "string" + }, + { + "name": "originator_iso", + "rawType": "object", + "type": "string" + }, + { + "name": "beneficiary_bank_id", + "rawType": "object", + "type": "string" + }, + { + "name": "beneficiary_bank", + "rawType": "object", + "type": "string" + }, + { + "name": "beneficiary_bank_country", + "rawType": "object", + "type": "string" + }, + { + "name": "beneficiary_iso", + "rawType": "object", + "type": "string" + }, + { + "name": "number_transactions", + "rawType": "float64", + "type": "float" + }, + { + "name": "amount_transactions", + "rawType": "float64", + "type": "float" + } + ], + "ref": "aae5219f-ecd9-47cd-87a3-98f4b7efb1bc", + "rows": [ + [ + "0", + "223935", + "2359", + "the-bank-of-new-york-mellon-corp", + "The Bank of New York Mellon Corp.", + "2011-02-10 00:00:00", + "2011-02-10 00:00:00", + "latvian-trade-commercial-bank", + "Latvian Trade Commercial Bank", + "Latvia", + "LVA", + "transcredit-bank-moscow-russia-rus", + "Transcredit Bank", + "Russia", + "RUS", + "1.0", + "3485.0" + ], + [ + "1", + "223936", + "2359", + "the-bank-of-new-york-mellon-corp", + "The Bank of New York Mellon Corp.", + "2011-02-03 00:00:00", + "2011-02-03 00:00:00", + "latvian-trade-commercial-bank", + "Latvian Trade Commercial Bank", + "Latvia", + "LVA", + "vnesheconombank-moscow-russia-rus", + "Vnesheconombank", + "Russia", + "RUS", + "1.0", + "599088.0" + ], + [ + "2", + "223937", + "2359", + "the-bank-of-new-york-mellon-corp", + "The Bank of New York Mellon Corp.", + "2011-02-02 00:00:00", + "2011-02-02 00:00:00", + "latvian-trade-commercial-bank", + "Latvian Trade Commercial Bank", + "Latvia", + "LVA", + "vnesheconombank-moscow-russia-rus", + "Vnesheconombank", + "Russia", + "RUS", + "1.0", + "1400000.0" + ], + [ + "3", + "223939", + "2359", + "the-bank-of-new-york-mellon-corp", + "The Bank of New York Mellon Corp.", + "2011-02-28 00:00:00", + "2011-02-28 00:00:00", + "latvian-trade-commercial-bank", + "Latvian Trade Commercial Bank", + "Latvia", + "LVA", + "ojsc-nomos-bank-moscow-russia-rus", + "Ojsc 'Nomos-Bank'", + "Russia", + "RUS", + "1.0", + "205.48" + ], + [ + "4", + "223940", + "2359", + "the-bank-of-new-york-mellon-corp", + "The Bank of New York Mellon Corp.", + "2011-02-28 00:00:00", + "2011-02-28 00:00:00", + "latvian-trade-commercial-bank", + "Latvian Trade Commercial Bank", + "Latvia", + "LVA", + "ojsc-nomos-bank-moscow-russia-rus", + "Ojsc 'Nomos-Bank'", + "Russia", + "RUS", + "1.0", + "790753.42" + ] + ], + "shape": { + "columns": 16, + "rows": 5 + } + }, + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idicij_sar_idfiler_org_name_idfiler_org_namebegin_dateend_dateoriginator_bank_idoriginator_bankoriginator_bank_countryoriginator_isobeneficiary_bank_idbeneficiary_bankbeneficiary_bank_countrybeneficiary_isonumber_transactionsamount_transactions
02239352359the-bank-of-new-york-mellon-corpThe Bank of New York Mellon Corp.2011-02-102011-02-10latvian-trade-commercial-bankLatvian Trade Commercial BankLatviaLVAtranscredit-bank-moscow-russia-rusTranscredit BankRussiaRUS1.03485.00
12239362359the-bank-of-new-york-mellon-corpThe Bank of New York Mellon Corp.2011-02-032011-02-03latvian-trade-commercial-bankLatvian Trade Commercial BankLatviaLVAvnesheconombank-moscow-russia-rusVnesheconombankRussiaRUS1.0599088.00
22239372359the-bank-of-new-york-mellon-corpThe Bank of New York Mellon Corp.2011-02-022011-02-02latvian-trade-commercial-bankLatvian Trade Commercial BankLatviaLVAvnesheconombank-moscow-russia-rusVnesheconombankRussiaRUS1.01400000.00
32239392359the-bank-of-new-york-mellon-corpThe Bank of New York Mellon Corp.2011-02-282011-02-28latvian-trade-commercial-bankLatvian Trade Commercial BankLatviaLVAojsc-nomos-bank-moscow-russia-rusOjsc 'Nomos-Bank'RussiaRUS1.0205.48
42239402359the-bank-of-new-york-mellon-corpThe Bank of New York Mellon Corp.2011-02-282011-02-28latvian-trade-commercial-bankLatvian Trade Commercial BankLatviaLVAojsc-nomos-bank-moscow-russia-rusOjsc 'Nomos-Bank'RussiaRUS1.0790753.42
\n", + "
" + ], + "text/plain": [ + " id icij_sar_id filer_org_name_id \\\n", + "0 223935 2359 the-bank-of-new-york-mellon-corp \n", + "1 223936 2359 the-bank-of-new-york-mellon-corp \n", + "2 223937 2359 the-bank-of-new-york-mellon-corp \n", + "3 223939 2359 the-bank-of-new-york-mellon-corp \n", + "4 223940 2359 the-bank-of-new-york-mellon-corp \n", + "\n", + " filer_org_name begin_date end_date \\\n", + "0 The Bank of New York Mellon Corp. 2011-02-10 2011-02-10 \n", + "1 The Bank of New York Mellon Corp. 2011-02-03 2011-02-03 \n", + "2 The Bank of New York Mellon Corp. 2011-02-02 2011-02-02 \n", + "3 The Bank of New York Mellon Corp. 2011-02-28 2011-02-28 \n", + "4 The Bank of New York Mellon Corp. 2011-02-28 2011-02-28 \n", + "\n", + " originator_bank_id originator_bank \\\n", + "0 latvian-trade-commercial-bank Latvian Trade Commercial Bank \n", + "1 latvian-trade-commercial-bank Latvian Trade Commercial Bank \n", + "2 latvian-trade-commercial-bank Latvian Trade Commercial Bank \n", + "3 latvian-trade-commercial-bank Latvian Trade Commercial Bank \n", + "4 latvian-trade-commercial-bank Latvian Trade Commercial Bank \n", + "\n", + " originator_bank_country originator_iso beneficiary_bank_id \\\n", + "0 Latvia LVA transcredit-bank-moscow-russia-rus \n", + "1 Latvia LVA vnesheconombank-moscow-russia-rus \n", + "2 Latvia LVA vnesheconombank-moscow-russia-rus \n", + "3 Latvia LVA ojsc-nomos-bank-moscow-russia-rus \n", + "4 Latvia LVA ojsc-nomos-bank-moscow-russia-rus \n", + "\n", + " beneficiary_bank beneficiary_bank_country beneficiary_iso \\\n", + "0 Transcredit Bank Russia RUS \n", + "1 Vnesheconombank Russia RUS \n", + "2 Vnesheconombank Russia RUS \n", + "3 Ojsc 'Nomos-Bank' Russia RUS \n", + "4 Ojsc 'Nomos-Bank' Russia RUS \n", + "\n", + " number_transactions amount_transactions \n", + "0 1.0 3485.00 \n", + "1 1.0 599088.00 \n", + "2 1.0 1400000.00 \n", + "3 1.0 205.48 \n", + "4 1.0 790753.42 " + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g_lva_rus._edges.head()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Find Oleg Deripaska's transaction\n", + "\n", + "Use contains() and between() predicates to find a specific transaction pattern." + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [], + "source": [ + "from graphistry import between\n", + "\n", + "chain_operations = graphistry.Chain([\n", + " n({\"nodeId\": contains(pat=\"expo\")}),\n", + " e_forward(hops=1, edge_match={\n", + " \"originator_bank_country\": \"Latvia\",\n", + " \"beneficiary_bank_country\": \"Russia\",\n", + " \"amount_transactions\": between(15800000, 16000000)}),\n", + " n({\"nodeId\": contains(pat=\"soyuz\")}, name=\"is_soyuz\")\n", + "])\n", + "g_od = g.gfql(chain_operations)" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.microsoft.datawrangler.viewer.v0+json": { + "columns": [ + { + "name": "index", + "rawType": "int64", + "type": "integer" + }, + { + "name": "id", + "rawType": "int64", + "type": "integer" + }, + { + "name": "icij_sar_id", + "rawType": "int64", + "type": "integer" + }, + { + "name": "filer_org_name_id", + "rawType": "object", + "type": "string" + }, + { + "name": "filer_org_name", + "rawType": "object", + "type": "string" + }, + { + "name": "begin_date", + "rawType": "datetime64[ns]", + "type": "datetime" + }, + { + "name": "end_date", + "rawType": "datetime64[ns]", + "type": "datetime" + }, + { + "name": "originator_bank_id", + "rawType": "object", + "type": "string" + }, + { + "name": "originator_bank", + "rawType": "object", + "type": "string" + }, + { + "name": "originator_bank_country", + "rawType": "object", + "type": "string" + }, + { + "name": "originator_iso", + "rawType": "object", + "type": "string" + }, + { + "name": "beneficiary_bank_id", + "rawType": "object", + "type": "string" + }, + { + "name": "beneficiary_bank", + "rawType": "object", + "type": "string" + }, + { + "name": "beneficiary_bank_country", + "rawType": "object", + "type": "string" + }, + { + "name": "beneficiary_iso", + "rawType": "object", + "type": "string" + }, + { + "name": "number_transactions", + "rawType": "float64", + "type": "float" + }, + { + "name": "amount_transactions", + "rawType": "float64", + "type": "float" + } + ], + "ref": "598952d5-69d7-4b38-b460-41dbaa9ad872", + "rows": [ + [ + "0", + "239549", + "2718", + "the-bank-of-new-york-mellon-corp", + "The Bank of New York Mellon Corp.", + "2013-08-15 00:00:00", + "2013-08-15 00:00:00", + "as-expobank", + "AS Expobank", + "Latvia", + "LVA", + "bank-soyuz-moscow-russia-rus", + "Bank Soyuz", + "Russia", + "RUS", + "1.0", + "15900000.0" + ] + ], + "shape": { + "columns": 16, + "rows": 1 + } + }, + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
idicij_sar_idfiler_org_name_idfiler_org_namebegin_dateend_dateoriginator_bank_idoriginator_bankoriginator_bank_countryoriginator_isobeneficiary_bank_idbeneficiary_bankbeneficiary_bank_countrybeneficiary_isonumber_transactionsamount_transactions
02395492718the-bank-of-new-york-mellon-corpThe Bank of New York Mellon Corp.2013-08-152013-08-15as-expobankAS ExpobankLatviaLVAbank-soyuz-moscow-russia-rusBank SoyuzRussiaRUS1.015900000.0
\n", + "
" + ], + "text/plain": [ + " id icij_sar_id filer_org_name_id \\\n", + "0 239549 2718 the-bank-of-new-york-mellon-corp \n", + "\n", + " filer_org_name begin_date end_date originator_bank_id \\\n", + "0 The Bank of New York Mellon Corp. 2013-08-15 2013-08-15 as-expobank \n", + "\n", + " originator_bank originator_bank_country originator_iso \\\n", + "0 AS Expobank Latvia LVA \n", + "\n", + " beneficiary_bank_id beneficiary_bank beneficiary_bank_country \\\n", + "0 bank-soyuz-moscow-russia-rus Bank Soyuz Russia \n", + "\n", + " beneficiary_iso number_transactions amount_transactions \n", + "0 RUS 1.0 15900000.0 " + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g_od._edges" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Visualize the specific transaction" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g_od_styled = (\n", + " g_od\n", + " .encode_edge_color('amount_transactions',\n", + " palette=nonlinear_palette_generator(1.05, palette),\n", + " as_continuous=True)\n", + " .settings(url_params={'play': 2000})\n", + ")\n", + "\n", + "# Uncomment to plot\n", + "g_od_styled.plot()" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g_od_styled = (\n", + " g_od\n", + " .encode_edge_color('amount_transactions',\n", + " palette=nonlinear_palette_generator(1.05, palette),\n", + " as_continuous=True)\n", + " .settings(url_params={'play': 2000})\n", + ")\n", + "g_od_styled.plot()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## In closing\n", + "\n", + "This notebook demonstrated the key GFQL operations:\n", + "\n", + "- **Node filtering**: `n()` with attribute matching and predicates\n", + "- **Edge traversal**: `e_forward()` with hop counts and edge matching\n", + "- **Chaining operations**: `graphistry.Chain()` to combine multiple operations\n", + "- **Predicates**:\n", + " - `is_in()` for matching multiple values\n", + " - `contains()` for substring matching\n", + " - `between()` for numeric range filtering\n", + "\n", + "### Additional Resources\n", + "\n", + "- [Python GFQL API Documentation](https://pygraphistry.readthedocs.io/en/latest/graphistry.compute.html#chain)\n", + "- [GFQL REST API Documentation](https://hub.graphistry.com/docs/GFQL/gfql-api/)\n", + "- [How GFQL Chain Works](https://hub.graphistry.com/docs/GFQL/)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "rapids-24.08", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.9" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} From bfb5b9895a6e37ce2117d22235846c401c477d80 Mon Sep 17 00:00:00 2001 From: Manfred Cheung Date: Mon, 8 Dec 2025 17:15:35 -0500 Subject: [PATCH 3/7] add changelog update --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1e7e16a73..5e428f3ece 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Development] +### Added +- **GFQL**: Added auto_graph_renderer_switching config option for Kepler maps. + ### Fixed - **GFQL:** `Chain` now validates on construction (matching docs) and rejects invalid hops immediately; pass `validate=False` to defer validation when assembling advanced flows (fixes #860). - **GFQL / eq:** `eq()` now accepts strings in addition to numeric/temporal values (use `isna()`/`notna()` for nulls); added coverage across validator, schema validation, JSON, and GFQL runtime (fixes #862). From 650ad9b314dca5eae4fc4962c1caa2e97c424fa4 Mon Sep 17 00:00:00 2001 From: Manfred Cheung Date: Mon, 8 Dec 2025 17:19:19 -0500 Subject: [PATCH 4/7] change code doc --- graphistry/kepler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphistry/kepler.py b/graphistry/kepler.py index b0bca59e58..0510d22c33 100644 --- a/graphistry/kepler.py +++ b/graphistry/kepler.py @@ -526,7 +526,7 @@ class KeplerConfig: :type overlay_blending: Optional[Literal['normal', 'additive', 'subtractive']] :param tile_style: Base map tile style configuration :type tile_style: Optional[Dict[str, Any]] - :param auto_graph_renderer_switching: Enable automatic graph renderer switching + :param auto_graph_renderer_switching: Enable automatic graph renderer switching, which allows Graphistry to hide Kepler node and edge layers depending on the mode (default: True) :type auto_graph_renderer_switching: Optional[bool] **Example: Structured parameters** From eed64b75b832f19c1000afdbf2851cfdb13f486c Mon Sep 17 00:00:00 2001 From: Manfred Cheung Date: Tue, 9 Dec 2025 20:10:44 -0500 Subject: [PATCH 5/7] respond to some PR comments --- .../fraud/icij_fincen_viz.ipynb} | 45 +++++++++---------- docs/source/notebooks/gfql.rst | 2 +- 2 files changed, 23 insertions(+), 24 deletions(-) rename demos/{gfql/ten_mins_to_gfql.ipynb => demos_by_use_case/fraud/icij_fincen_viz.ipynb} (99%) diff --git a/demos/gfql/ten_mins_to_gfql.ipynb b/demos/demos_by_use_case/fraud/icij_fincen_viz.ipynb similarity index 99% rename from demos/gfql/ten_mins_to_gfql.ipynb rename to demos/demos_by_use_case/fraud/icij_fincen_viz.ipynb index f999dc76f7..2647ed463b 100644 --- a/demos/gfql/ten_mins_to_gfql.ipynb +++ b/demos/demos_by_use_case/fraud/icij_fincen_viz.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# 10 mins to GFQL: ICIJ FinCEN Files Visualization\n", + "# ICIJ FinCEN Files Visualization\n", "\n", "This notebook demonstrates GFQL (Graph Query Language) using the ICIJ FinCEN Files dataset.\n", "\n", @@ -43,7 +43,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -684,7 +684,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -703,14 +703,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ - "chain_operations = graphistry.Chain([\n", + "chain_operations = [\n", " n(name=\"is_carib_bank_origin\"),\n", " e_forward(hops=1, edge_match={\"originator_bank_country\": is_in(options=carib_havens)}),\n", - "])\n", + "]\n", "g_carib_out = g.gfql(chain_operations)" ] }, @@ -1122,10 +1122,10 @@ "metadata": {}, "outputs": [], "source": [ - "chain_operations = graphistry.Chain([\n", + "chain_operations = [\n", " e_forward(hops=1, edge_match={\"beneficiary_bank_country\": is_in(options=carib_havens)}),\n", " n(name=\"is_carib_bank_destination\")\n", - "])\n", + "]\n", "g_carib_in = g.gfql(chain_operations)" ] }, @@ -1535,7 +1535,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -1578,7 +1578,6 @@ " .settings(url_params={'play': 2000})\n", ")\n", "\n", - "# Uncomment to plot\n", "g_carib_styled.plot()" ] }, @@ -1593,16 +1592,16 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "from graphistry import contains\n", "\n", - "chain_operations = graphistry.Chain([\n", + "chain_operations = [\n", " e_forward(hops=1, edge_match={\"originator_bank_country\": \"Latvia\", \"beneficiary_bank_country\": \"Russia\"}),\n", " n({\"nodeId\": contains(pat=\"\")}, name=\"is_rus_beneficiary\"),\n", - "])\n", + "]\n", "g_lva_rus = g.gfql(chain_operations)" ] }, @@ -2005,26 +2004,26 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ - "from graphistry import between\n", + "from graphistry import between, contains\n", "\n", - "chain_operations = graphistry.Chain([\n", + "chain_operations = [\n", " n({\"nodeId\": contains(pat=\"expo\")}),\n", " e_forward(hops=1, edge_match={\n", " \"originator_bank_country\": \"Latvia\",\n", " \"beneficiary_bank_country\": \"Russia\",\n", " \"amount_transactions\": between(15800000, 16000000)}),\n", " n({\"nodeId\": contains(pat=\"soyuz\")}, name=\"is_soyuz\")\n", - "])\n", + "]\n", "g_od = g.gfql(chain_operations)" ] }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -2117,7 +2116,7 @@ "type": "float" } ], - "ref": "598952d5-69d7-4b38-b460-41dbaa9ad872", + "ref": "528a9869-46c1-4232-a9d6-053e637367f6", "rows": [ [ "0", @@ -2222,7 +2221,7 @@ "0 RUS 1.0 15900000.0 " ] }, - "execution_count": 18, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -2240,7 +2239,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -2280,13 +2279,12 @@ " .settings(url_params={'play': 2000})\n", ")\n", "\n", - "# Uncomment to plot\n", "g_od_styled.plot()" ] }, { "cell_type": "code", - "execution_count": 22, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -2325,6 +2323,7 @@ " as_continuous=True)\n", " .settings(url_params={'play': 2000})\n", ")\n", + "\n", "g_od_styled.plot()" ] }, diff --git a/docs/source/notebooks/gfql.rst b/docs/source/notebooks/gfql.rst index a967eae076..99b18c033f 100644 --- a/docs/source/notebooks/gfql.rst +++ b/docs/source/notebooks/gfql.rst @@ -12,4 +12,4 @@ GFQL Graph queries GPU Benchmarking <../demos/gfql/benchmark_hops_cpu_gpu.ipynb> GFQL Remote mode <../demos/gfql/gfql_remote.ipynb> Python Remote mode <../demos/gfql/python_remote.ipynb> - + # ICIJ FinCEN Files Visualization <../demos/demos_by_user_case/icij_fincen_viz.ipynb> From e3ea83eb1b6985ad1e47300f8bfc3f868a3f787a Mon Sep 17 00:00:00 2001 From: Manfred Cheung Date: Wed, 10 Dec 2025 13:56:49 -0500 Subject: [PATCH 6/7] refactor icij fincen viz demo --- .../fraud/icij_fincen_viz.ipynb | 906 ++++++++++++++---- 1 file changed, 716 insertions(+), 190 deletions(-) diff --git a/demos/demos_by_use_case/fraud/icij_fincen_viz.ipynb b/demos/demos_by_use_case/fraud/icij_fincen_viz.ipynb index 2647ed463b..87a77ee1fe 100644 --- a/demos/demos_by_use_case/fraud/icij_fincen_viz.ipynb +++ b/demos/demos_by_use_case/fraud/icij_fincen_viz.ipynb @@ -8,6 +8,8 @@ "\n", "This notebook demonstrates GFQL (Graph Query Language) using the ICIJ FinCEN Files dataset.\n", "\n", + "This document will serve as an end-to-end demonstration of using Graphistry's GFQL to extract information out of a complex real-world dataset. For this purpose, we will use a dataset made available by the International Consortium of Investigative Journalists (ICIJ) as part of their reporting of leaked documents from the U.S. Department of Treasury’s Financial Crimes Enforcement Network, which include suspicious activity reports filed by U.S. banks acting as beneficiary or orginating banks in domestic transactions or as correspondent or intermediary banks in international transactions. More information about the dataset can be found at the ICIJ. In this tutorial, we will show how graph queries can be used to extract insights from large datasets and answer questions.\n", + "\n", "Based on: https://hub.graphistry.com/docs/GFQL/gfql/" ] }, @@ -43,7 +45,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 107, "metadata": {}, "outputs": [], "source": [ @@ -77,12 +79,12 @@ "source": [ "## Node-list sample\n", "\n", - "View a sample of the nodes in the graph." + "View a sample of the nodes in the graph. Each node represents a financial institution." ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 108, "metadata": {}, "outputs": [ { @@ -100,7 +102,7 @@ "type": "string" } ], - "ref": "05cea886-7891-4730-a624-01b6cfe3ca46", + "ref": "cfa51504-9fe6-47d0-98d5-a73e6f549641", "rows": [ [ "0", @@ -184,7 +186,7 @@ "4 latvian-trade-commercial-bank" ] }, - "execution_count": 3, + "execution_count": 108, "metadata": {}, "output_type": "execute_result" } @@ -199,12 +201,12 @@ "source": [ "## Edge-list sample\n", "\n", - "View a sample of the edges in the graph." + "View a sample of the edges in the graph. Each edge represents an aggregegation of financial transactions between two financial institutions within a specific time period." ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 109, "metadata": {}, "outputs": [ { @@ -297,7 +299,7 @@ "type": "float" } ], - "ref": "151add92-8624-459e-bab4-e27523b2edcb", + "ref": "ad822317-09b0-47f3-859e-31f29a27845c", "rows": [ [ "0", @@ -581,7 +583,7 @@ "4 NaN 1.200000e+04 " ] }, - "execution_count": 4, + "execution_count": 109, "metadata": {}, "output_type": "execute_result" } @@ -596,12 +598,12 @@ "source": [ "## Visualization Setup\n", "\n", - "Create a color palette for visualizing the graph." + "Create a color palette for visualizing the graph. This is not necessary to look at the graph structure but will make the resulting graph more interpretable." ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 112, "metadata": {}, "outputs": [], "source": [ @@ -627,14 +629,14 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 111, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", - " \n", " \n", " \n", " " @@ -1561,21 +1839,33 @@ "" ] }, - "execution_count": 14, + "execution_count": 120, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "g_carib = graphistry.edges(pd.concat([g_carib_in._edges, g_carib_out._edges], ignore_index=True), \n", - " \"originator_bank_id\", \"beneficiary_bank_id\").materialize_nodes()\n", + "g_carib = graphistry \\\n", + " .edges(pd.concat([g_carib_in._edges, g_carib_out._edges], ignore_index=True), \\\n", + " \"originator_bank_id\", \"beneficiary_bank_id\") \\\n", + " .nodes(pd.concat([g_carib_in._nodes, g_carib_out._nodes], ignore_index=True).drop_duplicates())\n", "\n", "g_carib_styled = (\n", " g_carib\n", + " .bind(node=\"nodeId\", point_label=\"nodeId\")\n", " .encode_edge_color('amount_transactions',\n", - " palette=nonlinear_palette_generator(1.05, palette),\n", - " as_continuous=True)\n", - " .settings(url_params={'play': 2000})\n", + " palette=nonlinear_palette_generator(1.05, palette),\n", + " as_continuous=True)\n", + " .encode_point_color(\"is_carib_bank\",\n", + " as_categorical=True,\n", + " categorical_mapping={True: \"red\", False: \"blue\"}) \n", + " .settings(\n", + " height=800,\n", + " url_params={\n", + " \"pointOpacity\": 0.6 if len(g_carib_in._nodes) > 1500 else 0.9,\n", + " \"edgeOpacity\": 0.3 if len(g_carib_in._edges) > 1500 else 0.9,\n", + " \"strongGravity\": True,\n", + " \"play\": 2000})\n", ")\n", "\n", "g_carib_styled.plot()" @@ -1585,16 +1875,44 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Single transaction subgraph\n", + "## Latvia-Russia subgraph\n", "\n", - "Find a specific transaction pattern: Latvia to Russia transactions in a specific amount range." + "Find all data following a specific transaction pattern: Latvia to Russia transactions in a specific amount range." ] }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 121, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "\n", + " \n", + " \n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": 121, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "from graphistry import contains\n", "\n", @@ -1602,12 +1920,157 @@ " e_forward(hops=1, edge_match={\"originator_bank_country\": \"Latvia\", \"beneficiary_bank_country\": \"Russia\"}),\n", " n({\"nodeId\": contains(pat=\"\")}, name=\"is_rus_beneficiary\"),\n", "]\n", - "g_lva_rus = g.gfql(chain_operations)" + "g_lva_rus = g.gfql(chain_operations)\n", + "\n", + "g_lva_rus = g_lva_rus.bind(edge_label=\"amount_transactions\")\n", + "g_lva_rus = g_lva_rus.encode_edge_color(\"amount_transactions\",\n", + " nonlinear_palette_generator(1.4, palette), as_continuous=True)\n", + "g_lva_rus = g_lva_rus.encode_point_color(\"is_rus_beneficiary\",\n", + " as_categorical=True,\n", + " categorical_mapping={True: \"red\", False: \"blue\"})\n", + "\n", + "g_lva_rus = g_lva_rus.settings(\n", + " height=800,\n", + " url_params={\n", + " \"pointOpacity\": 0.6 if len(g_lva_rus._nodes) > 1500 else 0.9,\n", + " \"edgeOpacity\": 0.3 if len(g_lva_rus._edges) > 1500 else 0.9,\n", + " \"strongGravity\": True,\n", + " \"play\": 2000})\n", + "g_lva_rus.plot()" + ] + }, + { + "cell_type": "code", + "execution_count": 122, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.microsoft.datawrangler.viewer.v0+json": { + "columns": [ + { + "name": "index", + "rawType": "int64", + "type": "integer" + }, + { + "name": "nodeId", + "rawType": "object", + "type": "string" + }, + { + "name": "is_rus_beneficiary", + "rawType": "bool", + "type": "boolean" + } + ], + "ref": "91b5eebd-38eb-4840-9376-a30c770e7ff0", + "rows": [ + [ + "0", + "latvian-trade-commercial-bank", + "False" + ], + [ + "1", + "ltb-bank-riga", + "False" + ], + [ + "2", + "norvik-banka-jsc", + "False" + ], + [ + "3", + "jsc-norvik-banka", + "False" + ], + [ + "4", + "rietumu-banka-jsc", + "False" + ] + ], + "shape": { + "columns": 2, + "rows": 5 + } + }, + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
nodeIdis_rus_beneficiary
0latvian-trade-commercial-bankFalse
1ltb-bank-rigaFalse
2norvik-banka-jscFalse
3jsc-norvik-bankaFalse
4rietumu-banka-jscFalse
\n", + "
" + ], + "text/plain": [ + " nodeId is_rus_beneficiary\n", + "0 latvian-trade-commercial-bank False\n", + "1 ltb-bank-riga False\n", + "2 norvik-banka-jsc False\n", + "3 jsc-norvik-banka False\n", + "4 rietumu-banka-jsc False" + ] + }, + "execution_count": 122, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g_lva_rus._nodes.head()" ] }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 123, "metadata": {}, "outputs": [ { @@ -1700,7 +2163,7 @@ "type": "float" } ], - "ref": "aae5219f-ecd9-47cd-87a3-98f4b7efb1bc", + "ref": "58886227-2ab8-48c2-b567-51fa8269bc55", "rows": [ [ "0", @@ -1984,7 +2447,7 @@ "4 1.0 790753.42 " ] }, - "execution_count": 16, + "execution_count": 123, "metadata": {}, "output_type": "execute_result" } @@ -1999,12 +2462,17 @@ "source": [ "### Find Oleg Deripaska's transaction\n", "\n", - "Use contains() and between() predicates to find a specific transaction pattern." + "Use contains() and between() predicates to find a specific transaction pattern described by the ICIJ:\n", + "\n", + "1. On Aug. 15, 2013, Mallow Capital Corp., in the British Virgin Islands, sent $15.9 million from its account at Expobank in Latvia\n", + "2. The funds were sent to Deutsche Bank Trust Company Americas in New York.\n", + "3. Deutsche Bank U.S. then sent the funds to the Bank of New York Mellon, which later flagged the transaction as suspicious.\n", + "4. The funds were then credited to Mallow Capital’s account at Bank Soyuz in Russia. The transaction was labeled a “funds transfer”." ] }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 124, "metadata": {}, "outputs": [], "source": [ @@ -2023,7 +2491,103 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 125, + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.microsoft.datawrangler.viewer.v0+json": { + "columns": [ + { + "name": "index", + "rawType": "int64", + "type": "integer" + }, + { + "name": "nodeId", + "rawType": "object", + "type": "string" + }, + { + "name": "is_soyuz", + "rawType": "bool", + "type": "boolean" + } + ], + "ref": "7846a1c3-19cc-4969-bfeb-6d49c88517d2", + "rows": [ + [ + "0", + "as-expobank", + "False" + ], + [ + "1", + "bank-soyuz-moscow-russia-rus", + "True" + ] + ], + "shape": { + "columns": 2, + "rows": 2 + } + }, + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
nodeIdis_soyuz
0as-expobankFalse
1bank-soyuz-moscow-russia-rusTrue
\n", + "
" + ], + "text/plain": [ + " nodeId is_soyuz\n", + "0 as-expobank False\n", + "1 bank-soyuz-moscow-russia-rus True" + ] + }, + "execution_count": 125, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "g_od._nodes.head()" + ] + }, + { + "cell_type": "code", + "execution_count": 126, "metadata": {}, "outputs": [ { @@ -2116,7 +2680,7 @@ "type": "float" } ], - "ref": "528a9869-46c1-4232-a9d6-053e637367f6", + "ref": "3a269bb6-f311-4b19-bd36-5676983283ff", "rows": [ [ "0", @@ -2221,13 +2785,13 @@ "0 RUS 1.0 15900000.0 " ] }, - "execution_count": 15, + "execution_count": 126, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "g_od._edges" + "g_od._edges.head()" ] }, { @@ -2239,69 +2803,24 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - " \n", - " \n", - " \n", - " " - ], - "text/plain": [ - "" - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "g_od_styled = (\n", - " g_od\n", - " .encode_edge_color('amount_transactions',\n", - " palette=nonlinear_palette_generator(1.05, palette),\n", - " as_continuous=True)\n", - " .settings(url_params={'play': 2000})\n", - ")\n", - "\n", - "g_od_styled.plot()" - ] - }, - { - "cell_type": "code", - "execution_count": null, + "execution_count": 128, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", - " \n", " \n", " \n", " " @@ -2310,7 +2829,7 @@ "" ] }, - "execution_count": 22, + "execution_count": 128, "metadata": {}, "output_type": "execute_result" } @@ -2321,7 +2840,14 @@ " .encode_edge_color('amount_transactions',\n", " palette=nonlinear_palette_generator(1.05, palette),\n", " as_continuous=True)\n", - " .settings(url_params={'play': 2000})\n", + " .encode_point_color(\"is_soyuz\", as_categorical=True, categorical_mapping={True: \"red\", False: \"blue\"})\n", + " .settings(\n", + " height=800,\n", + " url_params={\n", + " \"pointOpacity\": 0.6 if len(g_lva_rus._nodes) > 1500 else 0.9,\n", + " \"edgeOpacity\": 0.3 if len(g_lva_rus._edges) > 1500 else 0.9,\n", + " \"strongGravity\": True,\n", + " \"play\": 2000})\n", ")\n", "\n", "g_od_styled.plot()" @@ -2345,9 +2871,9 @@ "\n", "### Additional Resources\n", "\n", - "- [Python GFQL API Documentation](https://pygraphistry.readthedocs.io/en/latest/graphistry.compute.html#chain)\n", + "- [Python GFQL API Documentation](https://pygraphistry.readthedocs.io/en/latest/gfql/overview.html)\n", "- [GFQL REST API Documentation](https://hub.graphistry.com/docs/GFQL/gfql-api/)\n", - "- [How GFQL Chain Works](https://hub.graphistry.com/docs/GFQL/)" + "- [How GFQL Chain Works](https://hub.graphistry.com/docs/GFQL/gfql-chaining/)" ] } ], From d5bd4270e1cbd79be8eba373fe7dcddc0b63a00b Mon Sep 17 00:00:00 2001 From: Manfred Cheung Date: Wed, 10 Dec 2025 14:16:12 -0500 Subject: [PATCH 7/7] update changelog version --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e428f3ece..a896b1f2ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Development] +## [0.46.1 - 2025-12-10] + ### Added - **GFQL**: Added auto_graph_renderer_switching config option for Kepler maps.