Latest Questions tagged Arrays

Browse all latest questions tagged Arrays

Published 31 Aug, 2022
Python - Create pandas dataframe from numpy array

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',...

Published 26 Aug, 2022
Python - Python - Alternative for using numpy array as key in dictionary

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...

Published 29 Aug, 2022
Python - TypeError: Mismatch between array dtype ('float64') and format specifier

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'...

Published 20 Aug, 2022
Python - MySQL One-to-Many to JSON format

I have two MySQL tables: User (id, name) Sale (id, user, item) Where Sale(user) is a foreign key to User(id), so this is a one-to-many relationship (one user can make many sales). I'm trying to ge...

Published 23 Apr, 2022
Javascript - How to access array from another .js file?

I want to get a (Very large) array from another file so it doesn't take up space in my main js file but I cannot figure it out, I have spent about 2 - 3 days searching online but cannot find an answer...

Published 16 Apr, 2022
Javascript - Create an array with same element repeated multiple times

In Python, where [2] is a list, the following code gives this output: [2] * 5 # Outputs: [2,2,2,2,2] Does there exist an easy way to do this with an array in JavaScript? I wrote the following func...

Published 16 Apr, 2022
Javascript - Mini-Max Sum In JavaScript - How to Get the Minimum Sum And Maximum Sum of 4 Elements in a 5-Element Array

The key is to sort that array first, then the minimum will be the first element and the maximum will be the last, hence if you want to get the minimum set, it will be the array without the highest val...

Published 29 Aug, 2022
Python - argsort for a multidimensional ndarray

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,...

Published 19 Jun, 2022
Reactjs - add new field in every json object in a array javascript

I am working on a react app where I am fetching a JSON response from a route which is basically a list of JSON objects. Now I want to add a field in every JSON object according to another field in tha...

Published 05 Aug, 2022
Jquery - Replace Text in val with array - jquery

I am looking to replace text in a text area value with an array. I have already seen how to replace the text with a value $("#mySelector").val(function(i, v) { //index, current value return v.replace...

Published 16 Apr, 2022
Javascript - Get json data from url and put it into variable by JavaScript

I have a JSON data in a URL, I want to get all JSON data from the URL by JavaScript (without jQuery) and put it into variable tags. JSON Data: [ { "uniq":"AXk2_U9l" }, { "uniq":"AX0ap...

Published 01 Aug, 2022
Jquery - Convert JSON object to array using javascript

I have a jQuery ajax request which returns data in json format, how can we convert it and push in to an array. TIA. [{"Day":"Nov 03","Saavor Kitchen":null,"Home Kitchen":2,"Restaurant":null}, {"Day":...

Published 06 Jun, 2022
Javascript - How do you add multiple objects to an array? (JavaScript)

I'm not sure if I phrased the question right. I'm fairly new to JavaScript, and I'd like to add multiple objects (?) to an array. If I have this array: let arr = [{ firstname: "John", la...

Published 27 Jun, 2022
Python - Viewing .npy images

How can I view images stored with a .npy extension and save my own files in that format?

Published 24 Aug, 2022
Python - correlation between arrays in python

I have 2 arrays. a1 = [1,2,4] a2 = [3,4,5] how would I find the correlation between these 2 arrays using python. In matlab, you would do: corr(a1,a2) How to do this in python?