I ran into a similar situation recently. I just needed a quick and easy way to just look at specific columns.
Dependency Warning: Pandoc must be installed.
This code includes the creation of a 61x61 data frame. A subprocess is opened. Pandocs converts the data frame from a LaTex format to a Markdown table format. awk
is used to slice columns from the output. less
paginates the output.
To examine, for example, to examine the 10th column, I executed the following in the terminal: python print_pandas.py | awk '{ print $10 }' | less
Change the $10
value accordingly.
# contents of print_pandas.py
from subprocess import PIPE, Popen
import shlex
import numpy as np
import pandas as pd
# Create a large random data frame.
df = pd.DataFrame([np.random.uniform(size=61) for _ in range(61)])
s = df.to_latex()
p = Popen(shlex.split('pandoc -f latex -t markdown'),
stdin=PIPE, stdout=PIPE)
stdoutdata, _ = p.communicate(input=s.encode("utf-8"))
print(stdoutdata.decode("utf-8"))
