@@ -1799,8 +1799,9 @@ def rec_summarize(r, summaryfuncs):
17991799
18001800def rec_join (key , r1 , r2 , jointype = 'inner' , defaults = None , r1postfix = '1' , r2postfix = '2' ):
18011801 """
1802- join record arrays r1 and r2 on key; key is a tuple of field
1803- names. If r1 and r2 have equal values on all the keys in the key
1802+ join record arrays r1 and r2 on key; key is a tuple of field names
1803+ -- if key is a string it is assumed to be a single attribute
1804+ name. If r1 and r2 have equal values on all the keys in the key
18041805 tuple, then their fields will be merged into a new record array
18051806 containing the intersection of the fields of r1 and r2.
18061807
@@ -1812,10 +1813,13 @@ def rec_join(key, r1, r2, jointype='inner', defaults=None, r1postfix='1', r2post
18121813 The defaults keyword is a dictionary filled with
18131814 {column_name:default_value} pairs.
18141815
1815- The keywords r1postfix and r2postfix are postfixed to column names
1816+ The keywords r1postfix and r2postfix are postfixed to column names
18161817 (other than keys) that are both in r1 and r2.
18171818 """
18181819
1820+ if cbook .is_string_like (key ):
1821+ key = (key , )
1822+
18191823 for name in key :
18201824 if name not in r1 .dtype .names :
18211825 raise ValueError ('r1 does not have key field %s' % name )
@@ -1862,7 +1866,7 @@ def key_desc(name):
18621866
18631867
18641868 keydesc = [key_desc (name ) for name in key ]
1865-
1869+
18661870 def mapped_r1field (name ):
18671871 """ the column name in newrec that corresponds to the colmn in r1 """
18681872 if name in key or name not in r2 .dtype .names : return name
0 commit comments