uditig
uditig

Reputation: 1

Why is my Jupyter Notebook unable to even finish running a cell containing correct code?

Currently, I am working through an online course where I'm learning about Pandas and Series. The following code is supposed to return the time taken to run a particular loop or function but when I run this cell in Jupyter Notebook, it doesn't finish. Keeps on showing: In[*]

%%timeit -n 10
#creating a brand new series to work with
s = pd.Series(np.random.randint(0,1000,10000))

for label, value in s.iteritems():
   s.loc[label]= value+2

Not sure how I can solve this because, for the instructor, it finished running in around 272 ms.

Thanks for any help!

Upvotes: 0

Views: 197

Answers (1)

lutrarutra
lutrarutra

Reputation: 484

It does run, it just takes some time to finish and depending on your hardware it can take a while. You can change the last number in the third line to something smaller and it will finish it in no time:

s = pd.Series(np.random.randint(0,1000,100))

[*] is indicating that the cell is currently running

Upvotes: 1

Related Questions