best-practice-and-impact / gptables

Good Practice Tables - an XlsxWriter wrapper to write consistently formatted statistical tables to Excel.
http://gptables.rtfd.io
Other
35 stars 4 forks source link

write_workbook errors with all integer table #227

Open MarkPaulin opened 11 months ago

MarkPaulin commented 11 months ago

Describe the bug write_workbook throws an error if a table has only integer columns.

To Reproduce Steps to reproduce the behavior:

import gptables as gpt
import pandas as pd
df = pd.DataFrame({"a": [0], "b": [1]})
table = gpt.GPTable(df, table_name="table", title="numbers")
gpt.write_workbook(filename="example.xlsx", sheets={"table 1": table})

Expected behavior write_workbook should work with tables that have all integer columns.

Additional context The error comes from this line, which is checking if any cells contain only special characters. The way it works currently assumes gptable.table.stack() is a series of objects, but that isn't the case if all the columns are numeric.

I can submit a PR to bypass this check whenever gptable.table.stack() is a numeric type, if you think that's a suitable solution.

rowanhemsi commented 2 months ago

Thank you for flagging this Mark and sorry it has take so long for us to get back to you. We will take a look and try to get this fixed as soon as possible