1

I have a data frame and for each group in it I want to display a data frame specific only for this group and plot in Jupiter notebook.

for name, group in building_info.groupby(['building_category']):
    display(group)
    fig, ax = plt.subplots(nrows=1, ncols=1,figsize=(13,5))
    sns.displot(group.num_people, ax = ax)

First it will display all data frames for each group and only then it will produce the plots. I would like to have that display(group) is directly followed by a plot, so that I have a direct comparisons of the data with a plot.

2
  • Have you read this or this? Could you try that approach and if it fails ask specifically about the problem you encounter? Commented Sep 23, 2017 at 20:38
  • Also, this may be an alternative approach. Commented Sep 23, 2017 at 20:39

1 Answer 1

1

If you're using Jupyter you could try importing this library:

# Print multiple objects to screen in same shell 
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"

This allows you to print the dataframe and a plot right below it:

# Make dataframe
data = {'a' : np.random.randint(0, 10, size = 10),
        'b' : np.random.randint(0, 10, size = 10),
        'c' : np.random.randint(0, 10, size = 10)}

df = pd.DataFrame(data)

# Show df
df
# show plot
df.plot()
plt.show()
# Show df again
df
# Show plot again
df.plot()
plt.show()

Returns:

multiple objects

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.