python - How to write Pandas MultiIndex Dataframe w/mean to ReportLab table -


i have merged 2 pandas dataframes (course schedule , student evaluations) via inner join. produce .groupby() dataframe of course section course instructor. lastly, compute .mean() questions 1 through 4 , print results. how can write these results, multiindex, column titles, , analysis, reportlab table output pdf?

merged_df = pd.merge(left=evals_df, right=sched_df, left_on='course', right_on='course') byinstructor_df = merged_df[['q1', 'q2', 'q3', 'q4']].groupby([merged_df['primary_instructor_name'],                          merged_df['course_number'], merged_df['offering_number']]) print(byinstructor_df.mean()) 

current output using print:

bird, b                 3302          1               4.38 2.62 4.62 4.62 grouch, o               2201          2               4.23 2.69 4.00 4.23                                       3               4.68 3.42 4.42 4.42                         3303          2               3.80 2.85 3.25 3.65                         4425          1               4.50 3.50 4.00 4.88   monster, c              3312          1               4.52 3.22 4.09 4.22 

thanks guidance. -tom

according needs, can:

  • write code in jupyter notebook, dataframe nicer formatted in html. there option export notebook pdf (it require pdflatex).
  • export dataframe excel using to_excel method , format according needs before integration. note can export csv (to_csv) same thing.
  • use to_latex method produce export can integrated in latex source. full example given here
  • use tabulate package produce nicely formatted pure text output.

hope helps.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -