-
Notifications
You must be signed in to change notification settings - Fork 53
Add nrow
and ncol
#285
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
base: main
Are you sure you want to change the base?
Add nrow
and ncol
#285
Changes from 2 commits
2ff4a60
ccf71e0
27c4c48
5722256
30ee986
ca81386
f094263
acc8ac8
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "Tables" | ||
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" | ||
authors = ["quinnj <[email protected]>"] | ||
version = "1.7.0" | ||
version = "1.7.1" | ||
|
||
[deps] | ||
DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,16 @@ | |
|
||
# Turn any AbstractColumns into an AbstractRow iterator | ||
|
||
# get the number of rows in the incoming table | ||
function rowcount(cols) | ||
"Return the number of rows in the incoming table." | ||
function nrow(cols) | ||
|
||
names = columnnames(cols) | ||
isempty(names) && return 0 | ||
return length(getcolumn(cols, names[1])) | ||
end | ||
@deprecate rowcount(x) nrow(x) | ||
|
||
"Return the number of columns in the incoming table." | ||
ncol(cols) = length(columnnames(cols)) | ||
|
||
|
||
# a lazy row view into a AbstractColumns object | ||
struct ColumnsRow{T} <: AbstractRow | ||
|
@@ -86,7 +90,7 @@ function rows(x::T) where {T} | |
# first check if it supports column access, and if so, wrap it in a RowIterator | ||
if columnaccess(x) | ||
cols = columns(x) | ||
return RowIterator(cols, Int(rowcount(cols))) | ||
return RowIterator(cols, Int(nrow(cols))) | ||
# otherwise, if the input is at least iterable, we'll wrap it in an IteratorWrapper | ||
# which will iterate the input, validating that elements support the AbstractRow interface | ||
# and unwrapping any DataValues that are encountered | ||
|
Uh oh!
There was an error while loading. Please reload this page.