Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scatter_matrix in pandas returns lots of text - how to remove it? [closed]

When I use scatter_matrix function from pandas, I get lots of text like

array([[<matplotlib.axes._subplots.AxesSubplot object at 0x000001BD9F985860>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x000001BD9F9C0588>,

Anyone knows how to tell pandas not to return this text?

like image 347
Umberto Avatar asked Oct 23 '25 14:10

Umberto


1 Answers

The scatter_matrix function returns the array of axes it generates, in case you want to modify them.

In an interactive Python console (IPython, the last line of an IPython notebook cell, etc.), return values (apart from None) are printed to the console (or the output of the cell, respectively), to it easier to see what is going on. If you were to run scatter_matrix as part of a script, this would not be printed, it would just be thrown away.

If you assign the return value to a variable

axes = scatter_matrix(...)

you get no output. The same applies in IPython (including notebooks, not in vanilla python with the >>> prompt) when you execute an empty statement after the the calculation – which is what adding ; to the end of the line does

scatter_matrix(...);

there is no return value to be echoed, so there is not output.

Compare

In[1]: 5
Out[1]: 5

In[2]: x=5

In[3]: 5;

In[4]: 5; 6
Out[4]: 6
like image 72
Anaphory Avatar answered Oct 26 '25 05:10

Anaphory



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!