Skip to content
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

Feature Request: Export DataFrame to LaTeX #13

Open
jacobadenbaum opened this issue Jul 22, 2018 · 1 comment
Open

Feature Request: Export DataFrame to LaTeX #13

jacobadenbaum opened this issue Jul 22, 2018 · 1 comment

Comments

@jacobadenbaum
Copy link
Owner

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:

  1. Convert DataFrame to IndexedTable
  2. Update printing methods to allow the user to suppress printing the row index.

Neither of these is particularly hard. Just needs doing.

@lmh91
Copy link

lmh91 commented Feb 7, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants