2

This is my code:

import pandas as pd
df = pd.DataFrame({'value1': [1, 5, 9], 'value2': [56, 84, 98]})
df.hist()

but no plot popped up, the program just ran and stopped. I'm sure I have all the required packages, and I can plot with matplotlib like:

import matplotlib.pyplot as plt
import pandas as pd
df = pd.DataFrame({'value1': [1, 5, 9], 'value2': [56, 84, 98]})
plt.scatter(df['value1'], df['value2'])
plt.show()

I'm using windows 10 pro, python 3.6.4.

3
  • Where are you running the code ? Commented Mar 8, 2018 at 0:17
  • It work fine on my side Commented Mar 8, 2018 at 0:23
  • Do you call plt.show()? Commented Mar 8, 2018 at 8:00

1 Answer 1

6

You need to call plt.show() if you run your script from command line:

import matplotlib.pyplot as plt
import pandas as pd

df = pd.DataFrame({'value1': [1, 5, 9], 'value2': [56, 84, 98]})
df.hist()
plt.show()

If you are in a Jupyter notebook, you need turn on a suitable backend such as:

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.