{
"cells": [
{
"cell_type": "markdown",
"id": "a1b2c3d4-0001-0000-0000-000000000001",
"metadata": {},
"source": [
"# DataFrame Analytics\n",
"\n",
"Load the full registry into a pandas DataFrame and run analytics.\n",
"\n",
"Requires the analytics extra:\n",
"\n",
"```bash\n",
"pip install anchorregistry[analytics]\n",
"```\n",
"\n",
"> These examples run against Sepolia testnet (`network=\"sepolia\"`).\n",
"> To run against Base mainnet: replace `configure(network=\"sepolia\")` with `configure(network=\"base\")`.\n",
"> All function calls, record structures, and output shapes are identical across networks."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "a1b2c3d4-0001-0000-0000-000000000002",
"metadata": {},
"outputs": [],
"source": [
"# Cell 1 — setup\n",
"from anchorregistry import configure, get_all, to_dataframe, BASE_SEPOLIA_RPC, V1A_BASE_SEPOLIA\n",
"import pandas as pd\n",
"\n",
"configure(\n",
" network=\"base-sepolia\",\n",
" contract_address=V1A_BASE_SEPOLIA,\n",
" rpc_url=BASE_SEPOLIA_RPC, # swap for Infura / Alchemy URL for faster scans\n",
")\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "a1b2c3d4-0001-0000-0000-000000000003",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Shape: (5, 28)\n"
]
},
{
"data": {
"text/plain": [
"ar_id str\n",
"registered bool\n",
"artifact_type_index int64\n",
"artifact_type_name str\n",
"tx str\n",
"block int64\n",
"registrant str\n",
"manifest_hash str\n",
"parent_ar_id str\n",
"descriptor str\n",
"title str\n",
"author str\n",
"tree_id str\n",
"token_commitment str\n",
"research_doi str\n",
"research_institution str\n",
"research_co_authors str\n",
"research_url str\n",
"data_data_version str\n",
"data_format str\n",
"data_row_count str\n",
"data_schema_url str\n",
"data_url str\n",
"code_git_hash str\n",
"code_license str\n",
"code_language str\n",
"code_version str\n",
"code_url str\n",
"dtype: object"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Cell 2 — load full registry into DataFrame\n",
"df = to_dataframe(get_all())\n",
"print(f\"Shape: {df.shape}\")\n",
"df.dtypes"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "a1b2c3d4-0001-0000-0000-000000000004",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" ar_id | \n",
" title | \n",
" research_doi | \n",
" research_institution | \n",
" research_url | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" AR-2026-dPXazj6 | \n",
" test sepolia anchor | \n",
" | \n",
" | \n",
" https://anchorregistry.com/ | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" ar_id title research_doi research_institution \\\n",
"0 AR-2026-dPXazj6 test sepolia anchor \n",
"\n",
" research_url \n",
"0 https://anchorregistry.com/ "
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Cell 3 — filter by artifact type\n",
"# Type-specific data fields are flattened as {type_name}_{field_name}\n",
"# e.g. RESEARCH fields -> research_doi, research_institution, research_co_authors, research_url\n",
"research_df = df[df.artifact_type_name == \"RESEARCH\"]\n",
"cols = [\"ar_id\", \"title\", \"research_doi\", \"research_institution\", \"research_url\"]\n",
"research_df[[c for c in cols if c in research_df.columns]]"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "a1b2c3d4-0001-0000-0000-000000000005",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" ar_id | \n",
" artifact_type_name | \n",
" title | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" AR-2026-dPXazj6 | \n",
" RESEARCH | \n",
" test sepolia anchor | \n",
"
\n",
" \n",
" | 1 | \n",
" AR-2026-86pNXz1 | \n",
" DATA | \n",
" test sepolia data anchor | \n",
"
\n",
" \n",
" | 2 | \n",
" AR-2026-yPZBgoP | \n",
" CODE | \n",
" test show/hide toggle | \n",
"
\n",
" \n",
" | 3 | \n",
" AR-2026-A5kgam5 | \n",
" CODE | \n",
" test hide/show toggle | \n",
"
\n",
" \n",
" | 4 | \n",
" AR-2026-L5RMQQ6 | \n",
" CODE | \n",
" test show/hide toggle | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" ar_id artifact_type_name title\n",
"0 AR-2026-dPXazj6 RESEARCH test sepolia anchor\n",
"1 AR-2026-86pNXz1 DATA test sepolia data anchor\n",
"2 AR-2026-yPZBgoP CODE test show/hide toggle\n",
"3 AR-2026-A5kgam5 CODE test hide/show toggle\n",
"4 AR-2026-L5RMQQ6 CODE test show/hide toggle"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Cell 4 — filter by registrant\n",
"registrant_df = df[df.registrant == \"0xc7a7afde1177fbf0bb265ea5a616d1b8d7ed8c44\"]\n",
"registrant_df[[\"ar_id\", \"artifact_type_name\", \"title\"]]"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "a1b2c3d4-0001-0000-0000-000000000006",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"artifact_type_name\n",
"CODE 3\n",
"DATA 1\n",
"RESEARCH 1\n",
"dtype: int64"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Cell 5 — group by artifact type\n",
"df.groupby(\"artifact_type_name\").size().sort_values(ascending=False)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "a1b2c3d4-0001-0000-0000-000000000007",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"tree_id\n",
"0x06d9d299e3cea4b6e4d5f332ffb1a50f191ad942ed594b1bd734873fd2e42496 1\n",
"0x3cdfef20d8c9dc273fdd8d74245833b99cc6d87a1fbd40f6cd5293dcd59beaed 1\n",
"0xaed54c1022c6f3ac608de2a26c49859f451b268d378b5e6045643f18e6afc651 1\n",
"0xb7b004b53c169d317554f22176971e3e20b0f81612f1ea54ee60ec285ea66ff8 1\n",
"0xf07140ce4deaf3b5dac859091a079f82e9656f173593feda7895d940b8fa5d13 1\n",
"dtype: int64"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Cell 6 — tree analysis\n",
"df.groupby(\"tree_id\").size().sort_values(ascending=False)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.15"
}
},
"nbformat": 4,
"nbformat_minor": 5
}