I recently started using Pycharm instead of Jupyter on my laptop to do some light scientific work(mainly because I like how it auto-completes the code).
this code works fine I Jupyter
import sympy as sp
import matplotlib.pyplot as plt
x = sp.symbols("x")
sp.Integral(x, x)
but when I run it in Pycharm, nothing happens and I don't get any output and I don't know why.
Related
My Jupyter Notebook server freezes when I call the style property of a large pandas DataFrame, as in this example:
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randn(9999,3),columns=list("ABC"))
df.style
When I replace 9999 by 999 in the above code this issue doesn't occur. The same script also runs fine in the Anaconda prompt. What could be the cause of the freeze?
I trying to run the following code in Jupyter Notebook. But it didn't work and throw out that the server is done.
I could import mayavi, but I could not 'from mayavi import malb'
%gui qt
from mayavi import mlab
import numpy as np
x, y, z = np.mgrid[-10:10:20j, -10:10:20j, -10:10:20j]
s = np.sin(xyz)/(xyz)
mlab.pipeline.volume(mlab.pipeline.scalar_field(x,y,z,s))
mlab.savefig('test')
The sever just shut down.
I am trying to plot image using jupyter notebook.
import pylab as plt
import numpy as np
Z=np.array(((1,2,3,4,5),(4,5,6,7,8),(7,8,9,10,11)))
im = plt.imshow(Z, cmap='hot')
plt.colorbar(im, orientation='horizontal')
plt.show()
And I get some strange error.
When I ran same code in Pycharm, It worked but wont work in jupyter notebook.
.
When I run a program with PyCharm, it doesn't display graphs made with Matplotlib. E.g.:
import matplotlib.pyplot as plt
[...]
plt.imshow(montage(W / np.max(W)), cmap='coolwarm')
I tried calling
plt.interactive(False)
first, but it didn't make a difference.
Running the same program with ipython3, the graphs are displayed.
I set a default back-end for my system in matplotlibrc (TkAgg), and that did the trick.
The below code worked for me:
in pycharm-community-2018.2.2
import matplotlib.pyplot as plt
df.boxplot(column='ApplicantIncome')
plt.show()
In an Ipython notebook, I have defined a function to plot data. I would like to import the function in my current notebook to use it.
I tried to convert the mynotebook.ipynb to a mynotebook.py file and then just do
from mynotebook import myfunction
But I get an error.
The problem is that I wrote the original notebook with starting ipython with the option pylab.
That means that to make it work, instead of writing something like
x = arange(1,10)
y = arange(1,10)
scatter(x, y)
I should change it to the more explicit:
import numpy as np
import matplotlib as plt
x = np.arange(1,10)
y = np.arange(1,10)
plt.scatter(x, y)
In my case my file is quite complex and changing it will be a pain...
Is there a way to import my notebook without modifying the .py file line by line???
from matplotlib.pylab import *
will take care of all of your imports, but some of the interactive stuff (show etc) might not work correctly.