conda install -c blaze blaze
into
¶We just played with some interesting queries on baseball statistics
from blaze import Data, into, by, join
db = Data('sqlite:///data/lahman2013.sqlite')
joined = join(db.Salaries, db.Teams)
result = by(joined[['name', 'yearID']], avg=joined.salary.mean())
result
How do we now store this result or use it with other libraries?
The result itself is a Blaze expression, not terribly useful if we're not using Blaze.
type(result)
list
or np.array
¶Blaze follows normal conventions and so can be converted by standard constructors
list(result)
import numpy as np
np.array(result)
into
¶Alternatively, Blaze has registered itself into the into
project and so can migrate its results to any of those formats.
into('salaries.csv', result)
!head salaries.csv
Dump results
into the following formats
# Dump results into a Python set
# Dump results into a Pandas DataFrame
# Dump results into a JSON file, inspect the file to make sure that it came out ok