-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP use Tables.Columns instead of columntable
#247
Draft
kleinschmidt
wants to merge
8
commits into
master
Choose a base branch
from
dfk/columns
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e6a5365
WIP replace ColumnTable with Columns
kleinschmidt d7d1283
WIP
kleinschmidt 8a00097
Tables does this for us
kleinschmidt 89adab5
tables compat for Columns
kleinschmidt 3810c48
use Columns
kleinschmidt 8dcbf62
make it say Vector
kleinschmidt 6032e6e
need to matieralize after select before dropmissing
kleinschmidt 59601d8
do we _really_ need to specialize on Columns?
kleinschmidt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -112,16 +112,16 @@ julia> sch[term(:y)] | |||||
y(continuous) | ||||||
``` | ||||||
""" | ||||||
schema(data, hints=Dict{Symbol,Any}()) = schema(columntable(data), hints) | ||||||
schema(dt::D, hints=Dict{Symbol,Any}()) where {D<:ColumnTable} = | ||||||
schema(Term.(collect(fieldnames(D))), dt, hints) | ||||||
schema(ts::AbstractVector{<:AbstractTerm}, data, hints::Dict{Symbol}) = | ||||||
schema(ts, columntable(data), hints) | ||||||
schema(data, hints=Dict{Symbol,Any}()) = | ||||||
schema(Term.(collect(Tables.columnnames(data))), data, hints) | ||||||
|
||||||
# handle hints: | ||||||
schema(ts::AbstractVector{<:AbstractTerm}, dt::ColumnTable, | ||||||
hints::Dict{Symbol}=Dict{Symbol,Any}()) = | ||||||
sch = Schema(t=>concrete_term(t, dt, hints) for t in ts) | ||||||
function schema(ts::AbstractVector{<:AbstractTerm}, | ||||||
data, | ||||||
hints::Dict{Symbol}=Dict{Symbol,Any}()) | ||||||
data = Tables.Columns(Tables.columns(data)) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the advantage of wrapping the result of |
||||||
sch = Schema(t=>concrete_term(t, data, hints) for t in ts) | ||||||
end | ||||||
|
||||||
schema(f::TermOrTerms, data, hints::Dict{Symbol}) = | ||||||
schema(filter(needs_schema, terms(f)), data, hints) | ||||||
|
@@ -168,15 +168,15 @@ a(continuous) | |||||
""" | ||||||
concrete_term(t::Term, d, hints::Dict{Symbol}) = | ||||||
concrete_term(t, d, get(hints, t.sym, nothing)) | ||||||
concrete_term(t::Term, dt::ColumnTable, hint) = | ||||||
concrete_term(t, getproperty(dt, t.sym), hint) | ||||||
concrete_term(t::Term, dt::ColumnTable, hints::Dict{Symbol}) = | ||||||
concrete_term(t, getproperty(dt, t.sym), get(hints, t.sym, nothing)) | ||||||
concrete_term(t::Term, d, hint) = | ||||||
concrete_term(t, getcolumn(d, t.sym), hint) | ||||||
concrete_term(t::Term, d, hints::Dict{Symbol}) = | ||||||
concrete_term(t, getcolumn(d, t.sym), get(hints, t.sym, nothing)) | ||||||
concrete_term(t::Term, d) = concrete_term(t, d, nothing) | ||||||
|
||||||
# if the "hint" is already an AbstractTerm, use that | ||||||
# need this specified to avoid ambiguity | ||||||
concrete_term(t::Term, d::ColumnTable, hint::AbstractTerm) = hint | ||||||
concrete_term(t::Term, d::Tables.Columns, hint::AbstractTerm) = hint | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just
Suggested change
|
||||||
concrete_term(t::Term, x, hint::AbstractTerm) = hint | ||||||
|
||||||
# second possible fix for #97 | ||||||
|
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
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
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
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICT
TableOperations.dropmissing
operates row-wise (it calls filter). I'm afraid this is going to kill performance for data frames.Maybe an optimized method for column tables could be added? (EDIT: That's probably doable, as we can use a faster approach than
filter
since we know that the condition can be computed separately for each row.) Another solution would be to definedropmissing
in DataAPI, say thatdropmissing(::Any)
is owned by TableOperations, but havedropmissing(::DataFrame)
be defined in DataFrames.Also,
narrowtypes
is a much more costly operation that just doingnonmissingtype(eltype(col))
as it requires going over all entries. DataFrames'sdropmissing
does that by default, maybe TableOperations could take a similar argument.