Short code snippets for more efficient Python
Get Started with Ibis
import ibis
db = ibis.sqlite.connect('geography.db')
countries = db.table('countries')
countries.columns
Reading a parquet file
import pyarrow as pa, pyarrow.parquet as pq
#read parquet file as pyarrow table
table = pq.read_table("example.parquet")
print(table)
Write A Parquet File
import pyarrow as pa, pyarrow.parquet as pq, numpy as np
#create an array with 100 numbers from 0 to 99
arr = pa.array(np.arange(100))
#create a pyarrow table
table = pa.Table.from_arrays([arr], names=["col1"])
pq.write_table(table, "example.parquet", compression=None)
Create a PR
git status
git diff
git add <filenames>
commit -m "messages>"
git push origin <branch-name>
Top 10 python data projects on Github
import requests
import pandas as pd
url = 'https://api.github.com/search/repositories?q=data+language:python&sort=stars&order=desc'
res = requests.get(url)
res_dict = res.json()
repos = res_dict['items']
repo_df = pd.DataFrame(repos)
repo_df.head(10)