Combining two record arrays
I have two Numpy record arrays that have exactly the same fields. What is the easiest way to combine them into one (i.e. append one table on to the other)? ...
I have two Numpy record arrays that have exactly the same fields. What is the easiest way to combine them into one (i.e. append one table on to the other)? ...
Suppose I make two recarrays with the same dtype and stack them: >>> import numpy as np >>> dt = [('foo', int), ('bar', float)] >>> a = np.empty(2, dtype=dt).view(np.recarray) >>> b = np.empty(3, dtype=dt).view(np.recarray) >>> c = np.hstack((a,b)) Although a and b are recarrays, c is not: >>> c.foo Traceback (most recent call last):...
I have a conjunctive probability mass function array, with shape, for example (1,2,3,4,5,6) and I want to calculate the probability table, conditional to a value for some of the dimensions (export the cpts), for decision-making purposes. The code I came up with at the moment is the following (the input is the dictionary "vdict" of the f...
Hi, The following example shows what I want to do: >>> test rec.array([(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)], dtype=[('ifAction', '|i1'), ('ifDocu', '|i1'), ('ifComedy', '|i1')]) >>> test[['ifAction', 'ifDocu']][0] (0, 0) >>> test[['ifAction', 'ifDocu']][0]...
We've got a set of recarrays of data for individual days - the first attribute is a timestamp and the rest are values. Several of these: ts a b c 2010-08-06 08:00, 1.2, 3.4, 5.6 2010-08-06 08:05, 1.2, 3.4, 5.6 2010-08-06 08:10, 1.2, 3.4, 5.6 2010-08-06 08:15, 2.2, 3.3, 5.6 2010-08-06 08:20, 1.2, 3.4, 5.6 We'd l...
Suppose that I have an array defined by: data = np.array([('a1v1', 'a2v1', 'a3v1', 'a4v1', 'a5v1'), ('a1v1', 'a2v1', 'a3v1', 'a4v2', 'a5v1'), ('a1v3', 'a2v1', 'a3v1', 'a4v1', 'a5v2'), ('a1v2', 'a2v2', 'a3v1', 'a4v1', 'a5v2'), ('a1v2', 'a2v3', 'a3v2', 'a4v1', 'a5v2'), ('a1v2', 'a2v3', 'a3v2', 'a4v2', 'a...