Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

chore: update examples to replace deprecated functions #29

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/campaign-finance.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
" \"E\": \"recount\",\n",
" }\n",
" first_letter = pgi[0]\n",
" return first_letter.substitute(election_types, else_=ibis.NA)\n",
" return first_letter.substitute(election_types, else_=ibis.null())\n",
"\n",
"\n",
"cleaned = cleaned.mutate(election_type=get_election_type(_.TRANSACTION_PGI)).drop(\n",
Expand Down
26 changes: 13 additions & 13 deletions examples/imdb.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"To ensure column names are Pythonic, we can relabel as `snake_case`."
"To ensure column names are Pythonic, we can rename as `snake_case`."
]
},
{
Expand All @@ -102,15 +102,15 @@
"metadata": {},
"outputs": [],
"source": [
"name_basics.relabel(\"snake_case\")"
"name_basics.rename(\"snake_case\")"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's grab all of the relevant IMDB tables and relabel columns."
"Let's grab all of the relevant IMDB tables and rename columns."
]
},
{
Expand All @@ -119,13 +119,13 @@
"metadata": {},
"outputs": [],
"source": [
"name_basics = ex.imdb_name_basics.fetch().relabel(\"snake_case\")\n",
"title_akas = ex.imdb_title_akas.fetch().relabel(\"snake_case\")\n",
"title_basics = ex.imdb_title_basics.fetch().relabel(\"snake_case\")\n",
"title_crew = ex.imdb_title_crew.fetch().relabel(\"snake_case\")\n",
"title_episode = ex.imdb_title_episode.fetch().relabel(\"snake_case\")\n",
"title_principals = ex.imdb_title_principals.fetch().relabel(\"snake_case\")\n",
"title_ratings = ex.imdb_title_ratings.fetch().relabel(\"snake_case\")"
"name_basics = ex.imdb_name_basics.fetch().rename(\"snake_case\")\n",
"title_akas = ex.imdb_title_akas.fetch().rename(\"snake_case\")\n",
"title_basics = ex.imdb_title_basics.fetch().rename(\"snake_case\")\n",
"title_crew = ex.imdb_title_crew.fetch().rename(\"snake_case\")\n",
"title_episode = ex.imdb_title_episode.fetch().rename(\"snake_case\")\n",
"title_principals = ex.imdb_title_principals.fetch().rename(\"snake_case\")\n",
"title_ratings = ex.imdb_title_ratings.fetch().rename(\"snake_case\")"
]
},
{
Expand Down Expand Up @@ -420,7 +420,7 @@
"metadata": {},
"outputs": [],
"source": [
"ibis.show_sql(name_basics)"
"ibis.to_sql(name_basics)"
]
},
{
Expand All @@ -437,8 +437,8 @@
"metadata": {},
"outputs": [],
"source": [
"title_akas = title_akas.mutate(title_id=tconst_to_int(_.title_id)).relabel(\n",
" {\"title_id\": \"tconst\"}\n",
"title_akas = title_akas.mutate(title_id=tconst_to_int(_.title_id)).rename(\n",
" {\"tconst\": \"title_id\"}\n",
")\n",
"title_basics = title_basics.mutate(tconst=tconst_to_int(_.tconst))\n",
"title_crew = title_crew.mutate(\n",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ jupyterlab == 3.4.8
ipywidgets
altair
pandas < 2.1
ibis-framework[sqlite,duckdb,clickhouse]
ibis-framework[sqlite,duckdb,clickhouse,examples]
ibis-substrait < 3.1
53 changes: 27 additions & 26 deletions scripts/prepare_campaign_finance_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,34 @@
if not parquet_path.exists():
print("Generating itcont.parquet...")
# Read in the CSV
t = ibis.read_csv(csv_path)

# The CSV doesn't have a header, we need to manually add titles
header = [
"CMTE_ID",
"AMNDT_IND",
"RPT_TP",
"TRANSACTION_PGI",
"IMAGE_NUM",
"TRANSACTION_TP",
"ENTITY_TP",
"NAME",
"CITY",
"STATE",
"ZIP_CODE",
"EMPLOYER",
"OCCUPATION",
"TRANSACTION_DT",
"TRANSACTION_AMT",
"OTHER_ID",
"TRAN_ID",
"FILE_NUM",
"MEMO_CD",
"MEMO_TEXT",
"SUB_ID",
]
t = t.relabel(dict(zip(t.columns, header)))
t = ibis.read_csv(
csv_path,
header=False,
names=[
"CMTE_ID",
"AMNDT_IND",
"RPT_TP",
"TRANSACTION_PGI",
"IMAGE_NUM",
"TRANSACTION_TP",
"ENTITY_TP",
"NAME",
"CITY",
"STATE",
"ZIP_CODE",
"EMPLOYER",
"OCCUPATION",
"TRANSACTION_DT",
"TRANSACTION_AMT",
"OTHER_ID",
"TRAN_ID",
"FILE_NUM",
"MEMO_CD",
"MEMO_TEXT",
"SUB_ID",
],
)

# For the analysis, we're only going to use a few of the columns. To save
# bandwidth, lets select out only the columns we'll be using.
Expand Down