Category "numpy"

Scientific tick label notation tuning

I am not completely satisfied with the default scientific formatting for the tick labels. For example, import numpy as np import pylab pylab.rcParams['text.us

AttributeError: 'numpy.ndarray' object has no attribute 'split'

I am trying to answer the following question "A colleague has produced a file with one DNA sequence on each line. Download the file and load it into Python usi

ModuleNotFoundError: No module named 'numpy.core._multiarray_umath' on matplotlib import

I'm trying to run a simple testfile on a remote Server. But it throws a numpy error for matplotlib.pyplot. Here is the code import matplotlib.pyplot as plt impo

Does NumPy have a function equivalent to Matlab's buffer?

I see there is an array_split and split methods but these are not very handy when you have to split an array of length which is not integer multiple of the chun

Find and draw regression plane to a set of points

I want to fit a plane to some data points and draw it. My current code is this: import numpy as np from mpl_toolkits.mplot3d import Axes3D import matplotlib.py

Debug Python from Visual Studio Code - Importing Numpy

import numpy print "asdf" When I try to debug/run the above Python code in Visual Studio Code I get the following error (Using OSX) ImportError, cannot im

Vectorizing numpy.random.multinomial

I am trying to vectorize the following code: for i in xrange(s.shape[0]): a[i] = np.argmax(np.random.multinomial(1,s[i,:])) s.shape = 400 x 100 [

How to determine whether a column/variable is numeric or not in Pandas/NumPy?

Is there a better way to determine whether a variable in Pandas and/or NumPy is numeric or not ? I have a self defined dictionary with dtypes as keys and nume

Access Tensorflow tensor value

I have a tensor with the following properties. I want to save the numpy = 1 but I don't know how to access this value. How do I do this? test_labels[1] <tf.

Sphinx Extensions (numpydoc)

NOTE Added After: I finally got numpydoc working. It was also a python 2 problem. I ran 2to3 on it and now it seems to be working. OK, I've spent an entire d

Tensordot for numpy array and scipy sparse matrix

For a current project I have to compute the inner product of a lot of vectors with the same matrix (which is quite sparse). The vectors are associated with a tw

How to fix 'numpy.ndarray' object has no attribute 'get_figure' when plotting subplots

I have written the following code to plot 6 pie charts in different subplots, but I get an error. This code works correctly if I use it to plot only 2 charts, b

Is there a way to iteratively add plots to Animation.FuncAnimation()?

I'm working on my master thesis right now and need to animate a high number of points moving. Those points will be representing predators and prey. The number o

Python reshape list to ndim array

Hi I have a list flat which is length 2800, it contains 100 results for each of 28 variables: Below is an example of 4 results for 2 variables [0, 0, 1, 1,

Converting pandas.DataFrame to bytes

I need convert the data stored in a pandas.DataFrame into a byte string where each column can have a separate data type (integer or floating point). Here is a

How to use `cv2.findContours` in different OpenCV versions?

I am trying to use OpenCV with Python in order to detect squares in a live video feed from a Raspberry Pi camera. However, the cv2.GaussianBlur and cv2.Canny fu

How to use `cv2.findContours` in different OpenCV versions?

I am trying to use OpenCV with Python in order to detect squares in a live video feed from a Raspberry Pi camera. However, the cv2.GaussianBlur and cv2.Canny fu

How to fix IndexError: invalid index to scalar variable

This code generates error: IndexError: invalid index to scalar variable. at the line: results.append(RMSPE(np.expm1(y_train[testcv]), [y[1] for y in y_test])

2D array indexing

How can I do the indexing of some arrays used as indices? I have the following six 2D arrays like this- array([[2, 0], [3, 0], [3, 1], [5, 0], [5, 1

How to synchronize to curves on matplotlib?

I have two curves that have their maximum roughly at the same time, but I'd like to match them exactly. The first function, maxind, determines where the maximum