Problem with package TableView / Julia usage

First of all I would like to apologize if my question is too elementary. Although I have some experience with MS Excel VBA I am still a beginner at general use programming languages. Also, I would like to apologize for any misspelling, since English is not my first language.

Since I needed to do some rather complex string wrangles I decided to try Python last year so I would have more flexibility to code than in Excel and I really liked it. One problem arouse though, when I was facing a fuzzy logic problem for string matching in very large texts (and with loops). Pyhton was not handling the calculations well and was taking literally hours do finish my scripts.

So I decided to try Julia, and found the performance was indeed better, so I adopted the language as my working tool. The problem I have is that I like to work with dataframes which in my opinion is what better emulates the nice data visualization of Excel while allowing the flexibility of general programming languages.

Pandas was great and I could visualize data very well. DataFrames.jl is good, but the fact that it keeps omitting columns when displaying Data Frames kind of annoys me. For some of my dataframes even setting the Notebook ENV[“COLUMNS”] for huge values wont show all columns. Of course I could do show(df allcols = true), but that renders a really ugly and somewhat confusing vision of the DataFrame.

So searching the net I read about this Julia package (TableView.jl) that could render Julia data in a good way. After facing all kind of problems installing the package I finally was able to install it without warnings (actually I was having problem installing one of its dependencies, WebIO, which I think that I solved - or at least didnt throw me any more warnings).

But the problem is I just cannot use TableView.jl with dataframes. When I try

using DataFrames, TableView

A = rand(30, 20)
d = DataFrame(A)
showtable(d)

it throws me the following exception:

> MethodError: no method matching eachcolumn(::Tables.ColumnsRow{NamedTuple{(:x1, :x2, :x3, :x4, :x5, :x6, :x7, :x8, :x9, :x10, :x11, :x12, :x13, :x14, :x15, :x16, :x17, :x18, :x19, :x20),NTuple{20,Array{Float64,1}}}})
> Closest candidates are:
>   eachcolumn(!Matched::Union{Function, Type}, !Matched::Tables.Schema{names,nothing}, !Matched::Any) where names at C:\Users\marco\.julia\packages\Tables\okt7x\src\utils.jl:109
>   eachcolumn(!Matched::Union{Function, Type}, !Matched::Tables.Schema{names,types}, !Matched::Any) where {names, types} at C:\Users\marco\.julia\packages\Tables\okt7x\src\utils.jl:66
> 
> Stacktrace:
>  [1] table2json(::Tables.RowIterator{NamedTuple{(:x1, :x2, :x3, :x4, :x5, :x6, :x7, :x8, :x9, :x10, :x11, :x12, :x13, :x14, :x15, :x16, :x17, :x18, :x19, :x20),NTuple{20,Array{Float64,1}}}}, ::NTuple{20,Symbol}, ::NTuple{20,DataType}; requested::Nothing) at C:\Users\marco\.julia\packages\TableView\kqtYa\src\TableView.jl:210
>  [2] table2json at C:\Users\marco\.julia\packages\TableView\kqtYa\src\TableView.jl:204 [inlined]
>  [3] _showtable_sync!(::WebIO.Scope, ::NTuple{20,Symbol}, ::NTuple{20,DataType}, ::Tables.RowIterator{NamedTuple{(:x1, :x2, :x3, :x4, :x5, :x6, :x7, :x8, :x9, :x10, :x11, :x12, :x13, :x14, :x15, :x16, :x17, :x18, :x19, :x20),NTuple{20,Array{Float64,1}}}}, ::Array{NamedTuple{(:headerName, :editable, :headerTooltip, :field, :sortable, :resizable, :type, :filter),Tuple{Symbol,Bool,DataType,Symbol,Bool,Bool,String,String}},1}, ::Int64, ::Bool, ::String, ::WebIO.JSString) at C:\Users\marco\.julia\packages\TableView\kqtYa\src\TableView.jl:145
>  [4] showtable(::DataFrame; dark::Bool, height::Symbol, width::String, cell_changed::Nothing) at C:\Users\marco\.julia\packages\TableView\kqtYa\src\TableView.jl:139
>  [5] showtable(::DataFrame) at C:\Users\marco\.julia\packages\TableView\kqtYa\src\TableView.jl:62
>  [6] top-level scope at In[11]:1

I have tried to uninstall and reinstall both TableView and WebIO (Pkg.rm(“TableView”) Pkg.add(“TableView”), the same for “WebIO”) and I also tried to rebuid them (Pkg.build(“TableView”), Pkg.build(“WebIO”)) but to no avail.

I would also like to mention how straightforward were all my Python installations using conda install or pip install. Also, differences in documentation, TableView documentation, for instance, is rather shallow. Altough I understand that right now Python is a much more mature language (and Julia will catch up eventually) it might turn Julia in a somewhat intimidating language, especially for begginers like myself.

For what is worth it my editor is Jupyter Notebook version 6.0.3 (installed with Anaconda), my Julia kernel is version 1.4.0 and my OS is Windows 10.

Thank you in advance.

1 Like

You might want to look at PrettyTables.jl. It handles most tabular datastructures including DataFrames directly and can output LaTeX and html as well as straightforward printing. However it isn’t optimized for interactive browsing.

OP, I’m sorry to hear about your problems. Its frustrating when getting set up isn’t seamless, especially when you are used to something as battle-tested as excel.

I can replicate the error on Ubuntu with Julia 1.4.0. I installed IJulia and opened up a jupyter notebook with notebook(). Then I tried to use TableView like you did and got an error about WebIO not detected.

The error had a link to the troubleshooting page here. I ran

using WebIO
WebIO.install_jupyter_nbextension()

Then I closed out of everything and re-loaded the notebook. When I did showtable(df) it opened up an ag-grid pane beneath my cell, but didn’t fill it with anything. I didn’t get the error you had.

I then closed out of everything and did ] build. But I have the same behavior as above.

There is also BrowseTables.jl. It has fewer bells and whistles than TableView but is definitely faster. The command HTMLTable(df) will render a table the way you want.

EDIT: BrowseTables is a bit slow on my session with a 1000 x 200 data frame. So you might run into trouble even with this.

@js135005

I apreciate your response, I already installed the package and tried with my above mentioned df. I wasn’t able to display the entire df on Notebook, but I can see that package documentation is much more informative than what I found in TableView. Later on I will read it and definetely give it a try with my more complex dataframes.

Thank you!

@pdeffebach

I apreciate your response.

Regarding WebIO installation, besides what you did, I also ran “pip install jupyter_contrib_nbextensions” in Anaconda prompt, something that I found in Internet looking for solutions, but I don´t really know how much it helped. Wonder if it has something to do with the fact that we got different outputs using TableView…

Regarding BrowseTables.jl, I already installed it and used in my above mentioned df, and it worked wonderfully right away. Thank you!

I will try it in my more complex daraframes later.

Nonethless, I would really like to know what went wrong with my TableVIew installation, in case I face similar problem in the future. So if anyone else has any hints, it will be welcomed.

Regards.

I had the same problem using TableView with DataFrames, same error message.

Julia Version 1.4.1
Commit 381693d3df* (2020-04-14 17:20 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: AMD EPYC 7702P 64-Core Processor
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-8.0.1 (ORCJIT, znver1)
Environment:
JULIA_NUM_THREADS = 64
JULIA_EDITOR = “/usr/share/code/code”

ENV["COLUMNS"] seems not to work correctly.

using DataFrames
df = DataFrame()
for i=1:100
    df[!, Symbol(i)] = 1:10
end
ENV["COLUMNS"]="20"
df

Shows only 3 columns (not 20) for me when executed in Jupyter Lab (Jupyter Datascience Notebook Docker container).
Setting COLUMNS to very high numbers shows all columns.

Edit: Issue created:

I think ENV["COLUMNS"] works differently to what you expect - it basically set the horizontal space available to show columns (not sure in which metric…), and then showing the DataFrame will display as many columns as will fit in that available horizontal space, which will depend on how wide each column is.

Compare

df = DataFrame(rand(10, 1000))

with

df2 = DataFrame(rand(1:5, 10, 1000))

and you should see that more columns of df2 are displayed than of df for any value of ENV["COLUMNS"]. So you can’t interpret the number you put into the environment variable as the number of columns displayed.

Thanks for pointing this out!
Now I can even see this in the documentation, missed it before.

The issue has meanwhile been corrected …

Currently you have to do
]add TableView#master

to use TableView for dataframes

That fix is in the latest release.

1 Like

Thanks for clarifying, my version of TableView was kept at 0.4.1 due to parallel installation of WGLMakie.

@marco_zanon
Maybe you have a similar problem. So you may check your version of TableView by
]st TableView and update if it is not 0.6.0.

If updating leaves you with a lower version you could do

]add TableView@0.6.0 to find out, where the problem is.

@hhaensel
Now it works perfectly. Thank you for pointing this out.