1

i want to print or extract all columns and rows from my result data. The data is 61 rows and columns. The console displays like 6 or 7 columns and rows and fills the rest with dots but I need to obtain all the numbers. I uploaded an image of my data in the console. Image of the data with dots and missing columns and rows.

Your help is deeply appreciated!

Peter
  • 23
  • 1
  • 3
  • Can you provide the code you are currently using to output it? – Alex Jul 17 '19 at 18:54
  • You could print out each row individually with a for loop – Jake P Jul 17 '19 at 18:56
  • Possible duplicate of [Pretty-print an entire Pandas Series / DataFrame](https://stackoverflow.com/questions/19124601/pretty-print-an-entire-pandas-series-dataframe) – Damien Baldy Jul 17 '19 at 19:01
  • @Alex it's a very long code with an ordinary differential equation applied, but i just wrote "print("final results: ", df)" to print the data. – Peter Jul 17 '19 at 19:02
  • @DamienBaldy i just tried the answer to the question you linked, but I still got a reduced sample. – Peter Jul 17 '19 at 19:06
  • @Peter If one of the answers below helped you, please consider accepting it. – blthayer Jul 20 '19 at 18:04

2 Answers2

3

Check out the Pandas documentation. You should be able to set display for max_rows and max_columns like so:

import pandas as pd

pd.set_option("display.max_rows", None)
pd.set_option("display.max_columns", None)

As noted in the docs, None sets the limit to be unlimited. Warning: you're going to fill your console up very quickly with large frames.

If you have particularly wide columns, you may need to tinker with display.max_colwidth.

blthayer
  • 782
  • 1
  • 6
  • 19
0

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"))

Output in terminal

dmmfll
  • 2,666
  • 2
  • 35
  • 41