IterableTables defines a generic interface for tabular data.
The package currently has support for the following data sources:
any iterator who produces elements of type
The following data sinks are currently supported:
DataFrames (including things
The package is tightly integrated with Query.jl:
Any query that creates a named tuple in the last
@select statement (and
@collect the results into a data structure) is automatically an
iterable table data source, and any of the data sources mentioned above can
be queried using Query.jl.
This package only works on julia 0.5 and newer. You can add it with:
IterableTables makes it easy to conver between different table types in julia. It also makes it possible to use any table type in situations where packages traditionally expected a
For example, if you have a
using DataFrames df = DataFrame(Name=["John", "Sally", "Jim"], Age=[34.,25.,67.], Children=[2,0,3])
you can easily convert this into any of the supported data sink types by simply constructing a new table type and passing your source
using DataTables, TypedTables, IterableTables # Convert to a DataTable dt = DataTable(df) # Convert to a TypedTable tt = Table(df)
These conversions work in pretty much any direction. For example you can convert a
TypedTable into a
new_df = DataFrame(tt)
Or you can convert it to a
new_dt = DataTable(tt)
The general rule is that you can convert any sink into any source.
IterableTables also adds methods to a number of packages that have traditionally only worked with
DataFrames that make these packages work with any data source type defined in
For example, you can run a regression on any of the source types:
using GLM, DataFrames # Run a regression on a TypedTable lm(@formula(Children~Age),tt) # Run a regression on a DataTable lm(@formula(Children~Age),dt)
Or you can plot any of these data sources with
using Gadfly # Plot a TypedTable plot(tt, x=:Age, y=:Children, Geom.line) # Plot a DataTable plot(dt, x=:Age, y=:Children, Geom.line)
Again, this will work with any of the data sources listed above.
about 1 month ago