Created
February 18, 2021 17:06
-
-
Save xoelop/42f89018bd23604b534f225d3739024a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# loads the result of a query on Tinybird to a Pandas DataFrame | |
import pandas as pd | |
import urllib.parse | |
def build_tinybird_query_url(query: str, token: str) -> str: | |
url = f"https://api.tinybird.co/v0/sql?q={urllib.parse.quote(query + ' FORMAT CSVWithNames')}&token={token}" | |
return url | |
def df_from_tb(query: str, token: str) -> pd.DataFrame: | |
url = build_tinybird_query_url(query=query, token=token) | |
df = pd.read_csv(url, na_values=r'\N') | |
return df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment