TexTables.jl
TexTables.jl copied to clipboard
Feature Request: Export DataFrame to LaTeX
This is a little tricky since each row needs an index. This can be solved by indexing by row number, but I think a lot of people who want this feature will not be happy with the row number showing up. So, this feature will need to come in two parts:
- Convert DataFrame to IndexedTable
- Update printing methods to allow the user to suppress printing the row index.
Neither of these is particularly hard. Just needs doing.
I just needed this feature (DataFrame -> LaTeX-Table) and came up with this method. But I did not look too much into the package so there might be better implementations.
using DataFrames
import TexTables
function TexTables.regtable(df::DataFrames.DataFrame)
colnames = names(df)
cols = map(icol -> TexTables.TableCol(colnames[icol], collect(1:nrow(df)), df[!,colnames[icol]]), 1:ncol(df))
TexTables.regtable(cols...)
end
to_tex(regtable(df)) # df is the DataFrame to export