-
Notifications
You must be signed in to change notification settings - Fork 18
Propose some changes to DataFrames.jl API #68
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ LearnBase.getobs(dt::AbstractDataFrame, idx) = dt[idx,:] | |
|
||
LearnBase.nobs(dt::DataFrameRow) = 1 # it is a observation | ||
function LearnBase.getobs(dt::DataFrameRow, idx) | ||
idx == 1:1 || throw(ArgumentError( | ||
only(idx) == 1 || throw(ArgumentError( | ||
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. I understand that |
||
"Attempting to read multiple rows ($idx) with a single row")) | ||
|
||
return dt | ||
|
@@ -23,9 +23,12 @@ LearnBase.gettarget(::typeof(identity), dt::DataFrameRow) = | |
_throw_table_error() | ||
|
||
# convenience syntax to allow column name | ||
LearnBase.gettarget(col::Symbol, dt::AbstractDataFrame) = dt[1, col] | ||
LearnBase.gettarget(col::Symbol, dt::AbstractDataFrame) = | ||
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. I understand that for this to work we should make sure that the data frame has only one row. Right? Also the question is why do we only allow |
||
LearnBase.gettarget(col, only(dt)) | ||
LearnBase.gettarget(col::Symbol, dt::DataFrameRow) = dt[col] | ||
LearnBase.gettarget(fun, dt::AbstractDataFrame) = fun(dt) | ||
LearnBase.gettarget(fun, dt::AbstractDataFrame) = | ||
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. If I understand the intention correctly the |
||
LearnBase.gettarget(col, only(dt)) | ||
LearnBase.gettarget(fun, dt::DataFrameRow) = fun(dt) | ||
|
||
# avoid copy when target extraction function is supplied | ||
MLDataPattern.getobs_targetfun(dt::AbstractDataFrame) = dt | ||
|
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.
0.22 introduces
only