I am a beginner trying to learn simple pandas&numpy and I am using Pycharm. Why doesn't pycharm show all of the objects in numpy library as I am typing code? For instance I can't find int64, int32, float32 and such number types. After importing numpy as np, when I start typing np.int, Pycharm acts as if int is available but as if int32 and int64 didn't exist at all.
Here is a screenshot what the code suggestion box looks like: 1
I have the newest numpy (1.18.0) installed both through commandline to the python interpreter itself and in Pycharm to this particular project. I can also confirm that for example np.int64 is valid code - it executes in Pycharm without error:
import numpy as np
print(np.int64(123)) # Executes correctly even though Pycharm shows as if there's no int64 in numpy library
Related
I am doing a project and I need to use both tensorflow and pandas together.
The primary issue i am having is with the numpy version. If I have the latest version of numpy then tensorflow throws an error:
"Cannot convert a symbolic Tensor (lstm/strided_slice:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported"
If i downgrade numpy to 1.19.5 like the internet advises then importing pandas throws this error:
"numpy.ndarray size changed, may indicate binary incompatibility. expected 88 from c header, got 80 from pyobject"
Can someone please help?
Im learning numpy and derived types like int8, int32, etc are not showing in pycharm intellisense, only int, intc and similar are shown. In pycharm's python console it shows all the available types.
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.
I am a heavy user of jupyter notebook and, lately, I am running it using pypy instead of python to get extra speed. It works perfectly but I am missing matplotlib so much. Is there any decent 2D plotting library compatible with pypy and jupyter notebook? I don't need fancy stuff, scatter, line and bar plots would be more than enough.
Bokeh is working fairly good with pypy. The only problem I have encountered is linked to the use of numpy.datetime64 that is not yet supported by pypy. Fortunately it is enough to monkey-patch bokeh/core/properties.py and bokeh/util/serialization.py to pass in case of datetime64 reference.
I did it in this way:
bokeh/core/properties.py
...
try:
import numpy as np
datetime_types += (np.datetime64,)
except:
pass
...
and
bokeh/util/serialization.py
...
# Check for astype failures (putative Numpy < 1.7)
try:
dt2001 = np.datetime64('2001')
legacy_datetime64 = (dt2001.astype('int64') ==
dt2001.astype('datetime64[ms]').astype('int64'))
except:
legacy_datetime64 = False
pass
...
And managed to get nice looking plots in jupyter using pypy.
I am writing a script that I know I will run in Ipython.
I start Ipython as ipython --pylab.
This imports numpy, matplotlib, etc.
So do I have to specify these import statements again in my script?
I did not, and my script did not run.
Thanks for your help.
--pylab imports numpy both as * and np. I always use np. to minimize confusion.
If I need numpy in my script, I include the usual import numpy as np line. This lets me run the script from the shell. I can also run it with run ... from within IPython. I could also do an import in Ipython or some other script.
I've never tried omitting the import numpy line, and I don't see any need to start. It doesn't save any time or space. Make a habit of importing what you need, and don't assume the environment will do it for you.
Functions that you define and edit from with in IPython don't need their own import statements.
just tried this script:
def foo1(x):
return np.sum(x)
def foo2(x):
return x.sum()
Obviously I can load it with 'run'. And foo2(np.array([1,2,3])) works because the array uses its own method. But foo1 produces a NameError: global name 'np' is not defined.