recarray

Python – numpy – use somes recarray by json in one recarray

Python – numpy – use somes recarray by json in one recarray Question: My goal is to achieve simplified access to the various json files, with recarrays in a global recarray to achieve simplified end access like: parms.logic.myVarA. Desired structure parms (recarray) [ logic (recarray) – myVarA (int) tool (recarray) – myVarA (int) ] Example: …

Total answers: 1

numpy: How to add a column to an existing structured array?

numpy: How to add a column to an existing structured array? Question: I have a starting array such as: [(1, [-112.01268501699997, 40.64249414272372]) (2, [-111.86145708699996, 40.4945008710162])] The first column is an int and the second is a list of floats. I need to add a str column called ‘USNG’. I then create a structured numpy array, …

Total answers: 7

Passing a structured numpy array with strings to a cython function

Passing a structured numpy array with strings to a cython function Question: I am attempting to create a function in cython that accepts a numpy structured array or record array by defining a cython struct type. Suppose I have the data: a = np.recarray(3, dtype=[(‘a’, np.float32), (‘b’, np.int32), (‘c’, ‘|S5’), (‘d’, ‘|S3’)]) a[0] = (1.1, …

Total answers: 1

Sorting a python array/recarray by column

Sorting a python array/recarray by column Question: I have a fairly simple question about how to sort an entire array/recarray by a given column. For example, given the array: import numpy as np data = np.array([[5,2], [4,1], [3,6]]) I would like to sort data by the first column to return: array([[3,6], [4,1], [5,2]]) Asked By: …

Total answers: 5

Convert structured array to regular NumPy array

Convert structured array to regular NumPy array Question: The answer will be very obvious I think, but I don’t see it at the moment. How can I convert a record array back to a regular ndarray? Suppose I have following simple structured array: x = np.array([(1.0, 4.0,), (2.0, -1.0)], dtype=[(‘f0’, ‘<f8’), (‘f1’, ‘<f8’)]) then I …

Total answers: 5