Created
February 14, 2020 15:34
-
-
Save crawles/8c04959c67563d75d94b377d122cba0a to your computer and use it in GitHub Desktop.
Run a preview in bigquery using the `head` command. Save the result to a pandas df.
This file contains 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
from io import StringIO | |
def head(table, n=10): | |
head_list = !bq head --n $n --table $table | |
head_str = '\n'.join([head_list[1]] + head_list[3:-1]) | |
return pd.read_csv(StringIO(head_str), delimiter="|").iloc[:, 1:-1] | |
df = head('publicdata:samples.natality') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment