Printing a numpy array without an ellipse

I want to print a numpy array without truncation. I saw other solutions, but they don't seem to work.

Here is the code snippet:

total_list = np.array(total_list) np.set_printoptions(threshold=np.inf) print(total_list) 

And it looks like this:

 22 A 23 G 24 C 25 T 26 A 27 A 28 A 29 G .. 232272 G 232273 T 232274 G 232275 C 232276 T 232277 C 232278 G 232279 T 

This is all the code. Maybe I'm wrong in casting.

 import csv import pandas as pd import numpy as np seqs = pd.read_csv('BAP_GBS_BTXv2_imp801.hmp.csv') plts = pd.read_csv('BAP16_PlotPlan.csv') required_rows = np.array([7,11,14,19,22,31,35,47,50,55,58,63,66,72,74,79,82,87,90,93,99]) total_list = [] for i in range(len(required_rows)): curr_row = required_rows[i]; print(curr_row) for j in range(len(plts.RW)): if(curr_row == plts.RW[j]): curr_plt = plts.PI[j] curr_range = plts.RA1[j] curr_plt = curr_plt.replace("_", "").lower() if curr_plt in seqs.columns: new_item = [curr_row,curr_range,seqs[curr_plt]] total_list.append(new_item) print(seqs[curr_plt]) total_list = np.array(total_list) ''' np.savetxt("foo.csv", total_list[:,2], delimiter=',',fmt='%s') total_list[:,2].tofile('seqs.csv',sep=',',format='%s') ''' np.set_printoptions(threshold='nan') print(total_list) 
+13
python arrays numpy pandas
source share
4 answers

use the following snippet to get the ellipsis.

 import numpy numpy.set_printoptions(threshold=numpy.nan) 

EDIT:

If you have pandas.DataFrame use the following snippet to print your array:

 def print_full(x): pd.set_option('display.max_rows', len(x)) print(x) pd.reset_option('display.max_rows') 

Or you can use the pandas.DataFrame.to_string () method to get the desired result.

EDIT':

An earlier version of this post suggested an option below.

 numpy.set_printoptions(threshold='nan') 

Technically, this may work, but int and None are indicated as allowed types in empty documentation. Link: https://docs.scipy.org/doc/numpy/reference/generated/numpy.set_printoptions.html .

+14
source share

You can get around the weird Numpy Ret / Print behavior by changing it to list :

 print list(total_list) 

should print a list of 2-element np arrays.

+4
source share

You print numpy arrays not .

Add the following line after import:

 pd.set_option('display.max_rows', 100000) 
+3
source share
 #for a 2d array def print_full(x): dim = x.shape pd.set_option('display.max_rows', dim[0])#dim[0] = len(x) pd.set_option('display.max_columns', dim[1]) print(x) pd.reset_option('display.max_rows') pd.reset_option('display.max_columns') 
+1
source share

All Articles