Feb-29-2020, 07:08 PM
(This post was last modified: Feb-29-2020, 07:09 PM by jefsummers.)
Alternative -
Changing the value of stdout redirects all print (and the prompt part of input) statements to the new file. __stdout__ is the value of stdout when the program starts, so you do want to put it back once you are done with the text file generation.
import sys import pandas as pd sys.stdout = open('xxxstdout.txt','w') df = pd.DataFrame() print(df.describe)Then use a library function to convert the text file to a pdf.
Changing the value of stdout redirects all print (and the prompt part of input) statements to the new file. __stdout__ is the value of stdout when the program starts, so you do want to put it back once you are done with the text file generation.
sys.stdout = sys.__stdout__