2

I created a pandas dataframe using the below code. (See the extra code and plt.show() which is there to create a new plot every time or else we get one plot with all of them in the same plot)

%matplotlib inline

pd.DataFrame(
    np.array([[
        col,
        plt.scatter(data[col], data['SalePrice']) and plt.show()]
    for col in data.columns]),
    columns=['Feature', 'Scatter Plot']
)

But what I get is this

a pandas dataframe with some no-so-useful information about scatter plots

And at the end of the dataframe, I get all the scatter plots separately.

What I want is, for those graphs to get printed inline, inside the columns, just like the other values.

kaushalpranav
  • 1,725
  • 24
  • 39
  • 1
    I don't think this can be done. Pandas dataframes are not designed to handle objects like this. You can store the object, but to have print graphically I don't think pandas will do this. – Scott Boston May 20 '21 at 15:59
  • There _may_ be a way to do this using pandas styling and `to_html`, but it would still need to be viewed in a web browser, as in [this question and answer](https://stackoverflow.com/questions/14824522/dynamically-serving-a-matplotlib-image-to-the-web-using-python), not in-line – G. Anderson May 20 '21 at 17:00

0 Answers0