mpastell / Pweave

Pweave is a scientific report generator and a literate programming tool for Python. It can capture the results and plots from data analysis and works well with numpy, scipy and matplotlib.
http://mpastell.com/pweave
Other
435 stars 64 forks source link

Column names are not indented when printing pandas dataframes #81

Closed chendaniely closed 7 years ago

chendaniely commented 7 years ago

This seems to be something relatively new bug from 0.25 to 0.30

When printing out a dataframe, the column names are not indenting properly. The column names are being printed completely left-justified, meaning that the first column name is directly above the row index label.

$ pweave --version
Pweave 0.30

sample document:

\documentclass{article}
\begin{document}

<<>>=
import pandas as pd
print(pd.__version__)
@

<<>>=
df = pd.DataFrame({
    'column1': [1, 2, 3],
    'column2': [4, 5, 6]
})
print(df)
@
\end{document}

compiling the document

# saved the above document as pweave_print.texw
pweave -f tex pweave_print.texw
pdflatex pweave_print.tex

# open the document
xdg-open pweave_print.pdf

output: image

additional examples from my previously compiled documents:

old: image

new: image

Sorry about being overly active on the issue tracker. Have a book manuscript due this week. I can personally go back to 0.25 and use my hacky fix in #78, so there isn't any rush to fix the issue. I can also try to fix it myself if I'm directed to the place to look...

mpastell commented 7 years ago

Thanks for the report, I think I fixed it as your example works with the latest commit and no tests were broken.

Thanks for reporting the bugs you encounter! There have been major changes since 0.25 and clearly the tests don't catch everything.

chendaniely commented 7 years ago

thanks! installed from latest source Pweave 0.30.2dev and everything seems to be working as expected