class_docstr: A qualitative variable in a regression model
  
  A Factor is similar to R's factor. The levels of the Factor can be
  either strings or ints.
class_docstr_tok: ["A","qualitative","variable","in","a","regression","model","A","Factor","is","similar","to","R","'s","factor",".","The","levels","of","the","Factor","can","be","either","strings","or","ints","."]
docstr: Create a Factor from a column array.
  
  Parameters
  ----------
  col : ndarray
      an array with ndim==1
  name : str
      name of the Factor
  
  Returns
  -------
  factor : Factor
  
  Examples
  --------
  >>> data = np.array([(3,'a'),(4,'a'),(5,'b'),(3,'b')], np.dtype([('x', np.float64), ('y', 'S1')]))
  >>> f1 = Factor.fromcol(data['y'], 'y')
  >>> f2 = Factor.fromcol(data['x'], 'x')
  >>> d = f1.design(data)
  >>> print(d.dtype.descr)
  [('y_a', '<f8'), ('y_b', '<f8')]
  >>> d = f2.design(data)
  >>> print(d.dtype.descr)
  [('x_3', '<f8'), ('x_4', '<f8'), ('x_5', '<f8')]
docstr_tok: ["Create","a","Factor","from","a","column","array",".","Parameters","--","--","--","--","--","col",":","ndarray","an","array","with","ndim==1","name",":","str","name","of","the","Factor","Returns","--","--","--","-","factor",":","Factor","Examples","--","--","--","--",">",">",">","data","=","np.array","(","[","(","3",",","'","a","'",")",",","(","4",",","'","a","'",")",",","(","5",",","'","b","'",")",",","(","3",",","'","b","'",")","]",",","np.dtype","(","[","(","'","x","'",",","np.float64",")",",","(","'","y","'",",","'S1","'",")","]",")",")",">",">",">","f1","=","Factor.fromcol","(","data","[","'","y","'","]",",","'","y","'",")",">",">",">","f2","=","Factor.fromcol","(","data","[","'","x","'","]",",","'","x","'",")",">",">",">","d","=","f1.design","(","data",")",">",">",">","print","(","d.dtype.descr",")","[","(","'y_a","'",",","'","<","f8","'",")",",","(","'y_b","'",",","'","<","f8","'",")","]",">",">",">","d","=","f2.design","(","data",")",">",">",">","print","(","d.dtype.descr",")","[","(","'x_3","'",",","'","<","f8","'",")",",","(","'x_4","'",",","'","<","f8","'",")",",","(","'x_5","'",",","'","<","f8","'",")","]"]
code: def fromcol(col, name):
      """Create a Factor from a column array.
  
      Parameters
      ----------
      col : ndarray
          an array with ndim==1
      name : str
          name of the Factor
  
      Returns
      -------
      factor : Factor
  
      Examples
      --------
      >>> data = np.array([(3,'a'),(4,'a'),(5,'b'),(3,'b')], np.dtype([('x', np.float64), ('y', 'S1')]))
      >>> f1 = Factor.fromcol(data['y'], 'y')
      >>> f2 = Factor.fromcol(data['x'], 'x')
      >>> d = f1.design(data)
      >>> print(d.dtype.descr)
      [('y_a', '<f8'), ('y_b', '<f8')]
      >>> d = f2.design(data)
      >>> print(d.dtype.descr)
      [('x_3', '<f8'), ('x_4', '<f8'), ('x_5', '<f8')]
      """
      col = np.asarray(col)
      if col.ndim != 1 or (
          col.dtype.names and len(col.dtype.names) > 1
      ):
          raise ValueError(
              "expecting an array that can be thought "
              "of as a column or field of a recarray"
          )
      levels = np.unique(col)
      if not col.dtype.names and not name:
          name = "factor"
      elif col.dtype.names:
          name = col.dtype.names[0]
      return Factor(name, levels)
  
imports: import itertools
  import warnings
  from string import ascii_letters, digits
  import numpy
  import sympy
  from scipy.linalg import pinv
  from sympy import Dummy, default_sort_key
  from sympy.utilities.lambdify import implemented_function, lambdify
  from nipy.algorithms.utils.matrices import full_rank, matrix_rank
  from nipy.utils import VisibleDeprecationWarning, _NoValue
label_desc: Use image node_id 5 for calling the Factor obj's underlying member method code with example usage: obj.fromcol(col, name) and returns: Factor