-
Notifications
You must be signed in to change notification settings - Fork 372
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
add displaycoltypes to showrows & show for dataframes #2142
Merged
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
22fa765
add displaycoltypes to showrows show for dataframes
ssikdar1 d0df307
fix column width (eltypes calc) for displaycolumn bool
ssikdar1 052de9a
update show.jl w/ code review comments
ssikdar1 4890c3a
add displaycoltypes to showrows show for dataframes
ssikdar1 0f67963
Merge remote-tracking branch 'upstream/master' into show
ssikdar1 afec4ca
add coltypes to text/html show
ssikdar1 8485db6
Merge branch 'show' of https://github.com/ssikdar1/DataFrames.jl into…
ssikdar1 41b335b
change coltypes/displaycoltypes => eltypes
ssikdar1 cd4219f
add eltypes to text/latex
ssikdar1 b31502b
add eltypes to text/plain
ssikdar1 ebaf0b5
add tests for show plain latex html
ssikdar1 4ac1217
fix testset block
ssikdar1 5c904e4
cast dataframe test column to Int32 to work both on x86 and 64 bit tests
ssikdar1 3a7b031
fix show_eltype formatting
ssikdar1 4bb6529
wrap tests strings in triple quotes instead of single quotes
ssikdar1 de7e4e9
split functions onto multiple lines
ssikdar1 a9d733f
improve the visual formatting of the strings in io tests
ssikdar1 aaf4376
Apply suggestions from code review
nalimilan 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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -363,6 +363,7 @@ end | |||||
allcols::Bool = false, | ||||||
rowlabel::Symbol = :Row, | ||||||
displaysummary::Bool = true, | ||||||
displaycoltypes::Bool = true, | ||||||
rowid=nothing) | ||||||
|
||||||
Render a subset of rows (possibly in chunks) of an `AbstractDataFrame` to an | ||||||
|
@@ -390,6 +391,8 @@ NOTE: The value of `maxwidths[end]` must be the string width of | |||||
- `displaysummary::Bool`: Should a brief string summary of the | ||||||
AbstractDataFrame be rendered to the I/O stream before printing the | ||||||
contents of the renderable rows? Defaults to `true`. | ||||||
- `displaycoltype::Bool = true`: Whether to print the column type | ||||||
under the column name in the heading. Defaults to true. | ||||||
- `rowid = nothing`: Used to handle showing `DataFrameRow` | ||||||
|
||||||
# Examples | ||||||
|
@@ -417,6 +420,7 @@ function showrows(io::IO, | |||||
allcols::Bool = false, | ||||||
rowlabel::Symbol = :Row, | ||||||
displaysummary::Bool = true, | ||||||
displaycoltypes::Bool = true, | ||||||
rowid=nothing) # -> Void | ||||||
ncols = size(df, 2) | ||||||
|
||||||
|
@@ -463,23 +467,25 @@ function showrows(io::IO, | |||||
end | ||||||
|
||||||
# Print column types | ||||||
print(io, "│ ") | ||||||
padding = rowmaxwidth | ||||||
for itr in 1:padding | ||||||
write(io, ' ') | ||||||
end | ||||||
print(io, " │ ") | ||||||
for j in leftcol:rightcol | ||||||
s = compacttype(eltype(df[!, j]), maxwidths[j]) | ||||||
printstyled(io, s, color=:light_black) | ||||||
padding = maxwidths[j] - ourstrwidth(io, s) | ||||||
if displaycoltypes | ||||||
print(io, "│ ") | ||||||
padding = rowmaxwidth | ||||||
for itr in 1:padding | ||||||
write(io, ' ') | ||||||
end | ||||||
if j == rightcol | ||||||
print(io, " │\n") | ||||||
else | ||||||
print(io, " │ ") | ||||||
print(io, " │ ") | ||||||
for j in leftcol:rightcol | ||||||
s = compacttype(eltype(df[!, j]), maxwidths[j]) | ||||||
printstyled(io, s, color=:light_black) | ||||||
padding = maxwidths[j] - ourstrwidth(io, s) | ||||||
for itr in 1:padding | ||||||
write(io, ' ') | ||||||
end | ||||||
if j == rightcol | ||||||
print(io, " │\n") | ||||||
else | ||||||
print(io, " │ ") | ||||||
end | ||||||
end | ||||||
end | ||||||
|
||||||
|
@@ -537,6 +543,7 @@ function _show(io::IO, | |||||
splitcols = get(io, :limit, false), | ||||||
rowlabel::Symbol = :Row, | ||||||
summary::Bool = true, | ||||||
coltypes::Bool = true, | ||||||
rowid=nothing) | ||||||
_check_consistency(df) | ||||||
nrows = size(df, 1) | ||||||
|
@@ -569,6 +576,7 @@ function _show(io::IO, | |||||
allcols, | ||||||
rowlabel, | ||||||
summary, | ||||||
coltypes, | ||||||
rowid) | ||||||
return | ||||||
end | ||||||
|
@@ -607,6 +615,7 @@ while `splitcols` defaults to `true`. | |||||
By default this is the case only if `io` has the `IOContext` property `limit` set. | ||||||
- `rowlabel::Symbol = :Row`: The label to use for the column containing row numbers. | ||||||
- `summary::Bool = true`: Whether to print a brief string summary of the data frame. | ||||||
- `coltypes::Bool = true`: Whether to print the column types under column names in data frame. | ||||||
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.
Suggested change
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. Addressed in 052de9a |
||||||
|
||||||
# Examples | ||||||
```jldoctest | ||||||
|
@@ -630,16 +639,18 @@ Base.show(io::IO, | |||||
allcols::Bool = !get(io, :limit, false), | ||||||
splitcols = get(io, :limit, false), | ||||||
rowlabel::Symbol = :Row, | ||||||
summary::Bool = true) = | ||||||
summary::Bool = true, | ||||||
coltypes::Bool = true ) = | ||||||
ssikdar1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
_show(io, df, allrows=allrows, allcols=allcols, splitcols=splitcols, | ||||||
rowlabel=rowlabel, summary=summary) | ||||||
rowlabel=rowlabel, summary=summary, coltypes=coltypes) | ||||||
|
||||||
Base.show(df::AbstractDataFrame; | ||||||
allrows::Bool = !get(stdout, :limit, true), | ||||||
allcols::Bool = !get(stdout, :limit, true), | ||||||
splitcols = get(stdout, :limit, true), | ||||||
rowlabel::Symbol = :Row, | ||||||
summary::Bool = true) = | ||||||
summary::Bool = true, | ||||||
coltypes::Bool = true) = | ||||||
show(stdout, df, | ||||||
allrows=allrows, allcols=allcols, splitcols=splitcols, | ||||||
rowlabel=rowlabel, summary=summary) | ||||||
rowlabel=rowlabel, summary=summary, coltypes=coltypes) |
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.
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.
Addressed in 052de9a