How to increase the printed number of columns in python?

arrays, python

Solution

Set NumPy's print options:

numpy.set_printoptions(linewidth=whatever)

Problem

For columns more than 5, python prints columns in next line for the same row. For example: ``` >>> import numpy as np >>> x = np.random.rand(5,8) >>> x array([[ 0.1842756 , 0.09323525, 0.2910024 , 0.57115116, 0.6894235 , 0.97366307, 0.32833171, 0.870427 ], [ 0.47993437, 0.01394924, 0.83829772, 0.03822534, 0.01289683, 0.61385652, 0.38680997, 0.15549481], [ 0.12124796, 0.14482983, 0.41347171, 0.02592663, 0.21083298, 0.16138967, 0.93531758, 0.51078627], [ 0.25442897, 0.82625412, 0.90589188, 0.1533367 , 0.12980143, 0.89043485, 0.36364293, 0.54288548], [ 0.08695784, 0.03753765, 0.50422536, 0.08978102, 0.89556966, 0.48192554, 0.23764354, 0.65701369]]) ``` The screen has more space for printing columns, for example up to 10. How to make columns printed on the same line? Is it possible to avoid `pandas` for this?

Original source