[Numpy-discussion] Outer join ?
Wed Feb 11 23:24:39 CST 2009
I have the following data structure:
col1 | col2 | col3
For each key in the second column, I would like to create an array
where for all unique values in the first column, there will be either
a value or zero if there is no data available. Like so:
# 20080101, 20080201, 20080301, 20080601
key1 - 4, 6, 5, 0
key2 - 0, 0, 3.4, 5.6
Ideally, the results would end up in a 2d array.
What's the most efficient way to accomplish this? Currently, I am
getting a list of uniq col1 and col2 values into separate variables,
then looping through each unique value in col2
a = loadtxt(...)
dates = unique(a[:]['col1'])
keys = unique(a[:]['col2'])
for key in keys:
b = a[where(a[:]['col2'] == key)]
Thanks in advance.
More information about the Numpy-discussion