Skip to main content

Llamapy

This is a simple library designed to make interfacing between Airpy and Google Sheets easier.

Setup & dependencies:

To interface with Google Sheets, you must have a registered API key. The best walkthrough of how to get one with your Airbnb account lives here (you only need to follow through the 'Create Google APIs account' section and can ignore the rest). When you get your credentials, you will need to put them in a filepath called credentials/credentials.json from your base folder.
gspread is the only non-standard dependancy required for this library to function. Installation instructions can be found in the link. Other dependancies are datetime, numpy, and pandas. Additionally, Airpy is strongly recommended for querying purposes.

Using the package:

Spreadsheet(name, email) creates a spreadsheet object and shares it with specified Airbnb email accounts. If the spreadsheet you wish to work on already exists, you can go to the spreadsheet and share it with the client_email in your credentials.json file - you are then able to reference it by name. If the spreadsheet does not exist, you can put in any name and the emails of those you'd like to share the file with (including your own!), and the spreadsheet will be created.
Example:

import llamapy as lp

sh = lp.Spreadsheet('Test', 'alex.shannon@airbnb.com')       # creates a spreadsheet and shares it with your email
sh.show_worksheets()                                         # prints a list of associated worksheets in the spreadsheet
sh.share_with('brian.chesky123@airbnb.com')                  # shares the spreadsheet with additional parties

Worksheet(Spreadsheet, title, df, blank_sheet=False, row_offset=3, col_offset=1, title_text='', title_color='rausch', header_text_color='white', header_background_color='kazan', border_color='hof', text_color='hof', font_style='Proxima Nova') creates a worksheet associated with a given spreadsheet. It pushes a pandas dataframe to this worksheet, and performs general formatting to the sheet that can be specified when calling the function, all of which should be fairly self-explanatory. Special Airbnb colors that can be referenced are mapped to the original (and far superior) brand colors - rausch, kazan, hackberry, beach, hof, white.
Example:

import airpy as ap

# create 2 arbitrary dataframes, one from a query, and one with a basic python operation applied
df_1 = ap.presto.query("SELECT * FROM metrics.experiences_main__foundation WHERE ds = 2020-08-01 LIMIT 50")
df_2 = df1.describe()

ws_1 = lp.Worksheet(sh, 'exp_list', df_1, title_text='Sample of Experiences', font_style='Poppins')
ws_2 = lp.Worksheet(sh, 'Summary of Experiences', df_2, eader_background_color='hof', header_text_color='beach')

get_lp(days_ago=1) returns a string formatted as 'YYYY-MM-DD' for the specified number of days ago; this is meant to be a short hack to replace magic functions in Presto. Note that sometimes tables are 2+ days behind, and this function may need to be adjusted. It is encouraged to check the outputs of the query aren't missing any data before pushing them.

convert_lps(presto_query) also designed to make transitioning from Presto easier, this replaces any magic functions in a query with '{lp}', allowing you to copy and paste presto queries in their original form without worrying about replacing any text (making it easier to edit seemlessly between python & Superset).
Example:

query = '''
    SELECT *
    
    FROM core_experiences_dashboards.dim_experience_success
    
    WHERE ds = '{{ presto.latest_partition('core_experiences_dashboards.dim_experience_success') }}'
'''

latest_partition = get_lp(1)
query = convert_lps(query)
df = ap.presto.query(query.format(lp=latest_partition))
df.head()

This library is very much a work in progress. If you have any suggestions or find any bugs, please email alex.shannon@airbnb.com. Any feedback is much appreciated!

Metadata

Release files for llamapy 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llamapy 0.1.0
File Size Uploaded
llamapy-0.1.0.tar.gz 5.9 kB Details

Release files / llamapy-0.1.0.tar.gz

Download URL llamapy-0.1.0.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
aad8b81b9bdfeaa2ecbb176d5d4d429ce518eaf6b3ff54b0ee93c1b8e2b8131b
BLAKE2b-256 checksum
How to use checksums
7f5c4a63d39aea24a9f25d05bf53cb7166d4e0593fe3b65b836d89a4c3336714
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.7

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page