Skip to content

Instantly share code, notes, and snippets.

View marlenezw's full-sized avatar
🏠
Working from home

Marlene marlenezw

🏠
Working from home
View GitHub Profile
@marlenezw
marlenezw / inner_join
Created March 24, 2022 15:58
Use inner join to get most popular artists
artist_number_of_displays = art.mutate(c_artist=art['artist']).groupby("c_artist").count("display_title")
most_popular_artist = artists_at_portrero.inner_join(
artist_number_of_displays,
predicates=artists_at_portrero["artist"] == artist_number_of_displays["c_artist"]
).materialize()
@marlenezw
marlenezw / select_artists_at_location
Created March 24, 2022 15:57
get artists at location
artist_location = art["street_address_or_intersection", "artist"]
artists_at_portrero = artist_location.filter(artist_location["street_address_or_intersection"] == "1001 Portrero Avenue").distinct()
@marlenezw
marlenezw / groupby_and_sort
Created March 24, 2022 15:55
Use groupy and sort_by to get locations in San Francisco with the most art
art_loc = art.groupby("street_address_or_intersection").count('display_title')
most_art = art_loc.sort_by(ibis.desc(art_loc.display_title))
@marlenezw
marlenezw / filtering_data
Created March 24, 2022 15:54
filtering art based on artist name
adrianes_art = art.filter(art["artist"] == 'Colburn, Adriane')
adrianes_art
@marlenezw
marlenezw / distinct_and_count
Created March 24, 2022 15:53
select distinct artists and count them
distinct_artists = art["artist"].distinct()
distinct_artists.count()
@marlenezw
marlenezw / select_columns
Created March 24, 2022 15:50
Selecting columns from a table
art["artist", "display_title"]
@marlenezw
marlenezw / readable_table_name
Created March 24, 2022 13:44
Assign readable table name
art = db.table("civicArtTable")
art.columns
@marlenezw
marlenezw / list_db_tables
Created March 24, 2022 13:43
List out the tables in the database
db.list_tables()
@marlenezw
marlenezw / connecting_to_database
Created March 24, 2022 13:43
Connecting to sqlite database with ibis
import ibis
ibis.options.interactive = True
db = ibis.sqlite.connect("civicArt.db")
@marlenezw
marlenezw / check_sqlite_table_created
Created March 24, 2022 13:42
Check sqlite table has been created
.tables (this lets you check the table has been correctly created)
.schema civicArtTable (describes the table)