def addcols(X, cols, names=None):
if isinstance(names,str):<EOL><INDENT>names = [n.strip() for n in names.split('<STR_LIT:U+002C>')]<EOL><DEDENT>if isinstance(cols, list):<EOL><INDENT>if any([isinstance(x,np.ndarray) or isinstance(x,list) orisinstance(x,tuple) for x in cols]):<EOL><INDENT>assert all([len(x) == len(X) for x in cols]),'<STR_LIT>'<EOL>assert names != None and len(cols) == len(names),'<STR_LIT>'<EOL>cols = utils.fromarrays(cols,type=np.ndarray,names = names)<EOL><DEDENT>else:<EOL><INDENT>assert len(cols) == len(X), '<STR_LIT>'<EOL>cols = utils.fromarrays([cols], type=np.ndarray,names=names)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>assert isinstance(cols, np.ndarray)<EOL>if cols.dtype.names == None:<EOL><INDENT>cols = utils.fromarrays([cols],type=np.ndarray, names=names)<EOL><DEDENT><DEDENT>Replacements = [a for a in cols.dtype.names if a in X.dtype.names]<EOL>if len(Replacements) > <NUM_LIT:0>:<EOL><INDENT>print(('<STR_LIT>', <EOL>[a for a in cols.dtype.names if a in X.dtype.names]))<EOL><DEDENT>return utils.fromarrays(<EOL>[X[a] if a not in cols.dtype.names else cols[a] for a in X.dtype.names] + <EOL>[cols[a] for a in cols.dtype.names if a not in X.dtype.names], <EOL>type=np.ndarray,<EOL>names=list(X.dtype.names) + [a for a in cols.dtype.names <EOL>if a not in X.dtype.names])<EOL>
Add one or more columns to a numpy ndarray.

Technical dependency of :func:`tabular.spreadsheet.aggregate_in`.

Implemented by the tabarray method 
:func:`tabular.tab.tabarray.addcols`.

**Parameters**

        **X** :  numpy ndarray with structured dtype or recarray

                The recarray to add columns to.

        **cols** :  numpy ndarray, or list of arrays of columns

                Column(s) to add.

        **names**:  list of strings, optional

                Names of the new columns. Only applicable when `cols` is a 
                list of arrays.

**Returns**

        **out** :  numpy ndarray with structured dtype

                New numpy array made up of `X` plus the new columns.

**See also:**  :func:`tabular.spreadsheet.colstack`