[reportlab-users] pandas dataframe in a reportlab table

Pizzolato, Larissa (EC) larissa.pizzolato at canada.ca
Thu Feb 21 10:14:26 EST 2019


Thanks everyone! 

rlab_table_data=[['Mean','Max','Min','TestA','TestB']]+df.values.tolist() 

worked like a charm! 


-----Original Message-----
From: Robin Becker <robin at reportlab.com> 
Sent: February 21, 2019 9:38 AM
To: reportlab-users <reportlab-users at lists2.reportlab.com>; Pizzolato, Larissa (EC) <larissa.pizzolato at canada.ca>
Subject: Re: [reportlab-users] pandas dataframe in a reportlab table

A python person says that we should probably use tolist


rlab_table_data=[['Mean','Max','Min','TestA','TestB']]+df.values.tolist()


and that is indeed fast


> $ python -mtimeit -s'import pandas as pd;df=pd.DataFrame([[1,2,3,4,5],[1,2,3,4,5],[1,2,3,4,5]])' "rlab_table_data=[['Mean','Max','Min','TestA','TestB']]+df.values.tolist()"
> 100000 loops, best of 3: 7.72 usec per loop





On 20/02/2019 21:49, Pizzolato, Larissa (EC) wrote:
> 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]]
..........

-- 
Robin Becker


More information about the reportlab-users mailing list