Thonny with Pandas

1,988 views
Skip to first unread message

Arny T

unread,
Oct 26, 2017, 2:09:05 AM10/26/17
to thonny
I am running the following Pandas script in Thonny, after installing all the packages using Package Manager. 
However, upon completion of the script, there is no plot displayed, and the script runs without displaying any errors. 
Is this an issue with the IDE or does Pandas require a different IDE or setup?

import pandas as pd
import matplotlib.pyplot as plt
df  = pd.read_csv("C:\\Users\\arny\\data.csv")
df.plot()  # plots all columns against index
df.plot(kind='scatter',x='x',y='y') # scatter plot
df.plot(kind='density')  # estimate density function
# df.plot(kind='hist')  # histogram


Aivar Annamaa

unread,
Oct 26, 2017, 3:37:01 AM10/26/17
to thonny
Hi!

Try putting plt.show() in the end of the script, eg:

import numpy as np

import pandas as pd
import matplotlib.pyplot as plt

d = {'one' : np.random.rand(10),
     'two' : np.random.rand(10)}

df = pd.DataFrame(d)

df.plot(style=['o','rx'])
df.plot(style=['-','rx'])
plt.show()


(This is something Jupyter notebook takes care for you, but Thonny doesn't include special support for matplotlib)

best regards,
Aivar
Reply all
Reply to author
Forward
0 new messages