[reportlab-users] pandas dataframe in a reportlab table

Pizzolato, Larissa (EC) larissa.pizzolato at canada.ca
Wed Feb 20 16:49:10 EST 2019


Hi there,

I am seeking a way to input a pandas dataframe into an existing reportlab table.

So far I have tried numerous different things, with this being the most recent:

example_df = inputPandasDataframe.values.astype(str) # the data looks like this:[[1,2,3,4,5],[1,2,3,4,5],[1,2,3,4,5]]


rlab_table_data = [['Mean','Max','Min','TestA','TestB'], example_df]]



Rlab_Table = Table(rlab_table_data)



However, the result of this is each row being placed under an individual column like so:



[['Mean','Max','Min','TestA','TestB'],

[[1,2,3,4,5], [1,2,3,4,5], [1,2,3,4,5],'',''],

['','','','',''],

['','','','','']]

My desired result is:

rlab_table_data = [['Mean','Max','Min','TestA','TestB'],

                   [1,2,3,4,5],

                  [1,2,3,4,5],

                  [1,2,3,4,5]]

If you have some insight on this I'd really appreciate any advice!

Cheers!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20190220/6705c938/attachment.html>


More information about the reportlab-users mailing list