Browse all latest questions tagged Numpy

Votes

Published 31 Aug, 2022

I want to plot a 5 x 4 plots. The code for the same is below fig, axis = plt.subplots(5, 4,figsize=[25,10]) i = 0 for channel in np.unique(data_recent['channel_id']): for year in np.unique(data_r...

Votes

Published 31 Aug, 2022

To create a pandas dataframe from numpy I can use : columns = ['1','2'] data = np.array([[1,2] , [1,5] , [2,3]]) df_1 = pd.DataFrame(data,columns=columns) df_1 If I instead use : columns = ['1',...

Votes

Published 27 Aug, 2022

I have been trying to convert a numpy array to PIL image using Image.fromarray but it shows the following error. Traceback (most recent call last): File "C:\Users\Shri1008 Saurav Das\AppData...

Votes

Published 31 Aug, 2022

I'm trying to get HashMap type of functionality to work with tensorflow. I got it to work when keys and values are of int type. But when they are arrays it gives error - ValueError: Shapes (2,) and ()...

Votes

Published 01 May, 2022

I have a matrix with these dimensions (150,2) and I want to duplicate each row N times. I show what I mean with an example. Input: a = [[2, 3], [5, 6], [7, 9]] suppose N= 3, I want this output:...

Votes

Published 21 Aug, 2022

I have a set of points in a text file: random_shape.dat. The initial order of points in the file is random. I would like to sort these points in a counter-clockwise order as follows (the red dots are...

Votes

Published 26 Aug, 2022

I'm pretty new to Python numpy. I was attempted to use numpy array as the key in dictionary in one of my functions and then been told by Python interpreter that numpy array is not hashable. I've just...

Votes

Published 29 Aug, 2022

I have a numpy array with dimension 1000*30*150. I am trying to save it as txt file. So far I have tried this np.savetxt("test.txt", mydata, fmt='%.5f', delimiter=",") #and with open('test.txt', 'w'...

Votes

Published 31 Aug, 2022

Consider the following Python code which does some simple arithmetic operations over complex numbers in Python: import numpy as np s = 2 l = 5 v = np.array([np.exp(1j*2*np.pi/l)]) A = pow(s*v, l) +...

Votes

Published 22 Aug, 2022

I would like to convert a sentence to an array of one-hot vector. These vector would be the one-hot representation of the alphabet. It would look like the following: "hello" # h=7, e=4 l=11 o=14 wo...

Votes

Published 25 Aug, 2022

Let us consider the following pandas dataframe: df = pd.DataFrame([[1,np.array([6,7])],[4,np.array([8,9])]], columns = {'A','B'}) where the B column is composed by two numpy arrays. If we save t...

Votes

Published 25 Aug, 2022

If A is a TensorFlow variable like so A = tf.Variable([[1, 2], [3, 4]]) and index is another variable index = tf.Variable([0, 1]) I want to use this index to select columns in each row. In thi...

Votes

Published 29 Aug, 2022

I'm trying to get the indices to sort a multidimensional array by the last axis, e.g. >>> a = np.array([[3,1,2],[8,9,2]]) And I'd like indices i such that, >>> a[i] array([[1, 2,...

Votes

Published 29 Aug, 2022

I would like students to solve a quadratic program in an assignment without them having to install extra software like cvxopt etc. Is there a python implementation available that only depends on NumPy...

Votes

Published 01 May, 2022

I am trying to send a dataframe using socket programming.For that I need to know how to encode a dataframe into bytes at the client and then decode it into a dataframe at the server.

Popular Questions