1

I have merged two Pandas dataframes (course schedule and student evaluations) via an inner join. I then produce a .groupby() dataframe of course section by course by instructor. Lastly, I compute the .mean() for questions 1 through 4 and print the results. How can I write these results, multiindex, column titles, and analysis, to a ReportLab Table for output to a 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 for any guidance. -Tom

1 Answer 1

-1

According to your needs, you can:

  • Write your code in a Jupyter notebook, the DataFrame will look nicer formatted in HTML. There is also an option to export the notebook to PDF (it will require pdflatex).
  • Export the DataFrame to Excel by using the to_excel method and format it according to your needs before integration. Note that you can also export to CSV (to_csv) to do the same thing.
  • Use the to_latex method to produce an export that can be integrated in your latex source. A full example is given here
  • Use the tabulate package to produce a nicely formatted pure text output.

Hope it helps.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.