class_docstr: An :class:`NAAction` object defines a strategy for handling missing
  data.
  
  "NA" is short for "Not Available", and is used to refer to any value which
  is somehow unmeasured or unavailable. In the long run, it is devoutly
  hoped that numpy will gain first-class missing value support. Until then,
  we work around this lack as best we're able.
  
  There are two parts to this: First, we have to determine what counts as
  missing data. For numerical data, the default is to treat NaN values
  (e.g., ``numpy.nan``) as missing. For categorical data, the default is to
  treat NaN values, and also the Python object None, as missing. (This is
  consistent with how pandas does things, so if you're already using
  None/NaN to mark missing data in your pandas DataFrames, you're good to
  go.)
  
  Second, we have to decide what to do with any missing data when we
  encounter it. One option is to simply discard any rows which contain
  missing data from our design matrices (``drop``). Another option is to
  raise an error (``raise``). A third option would be to simply let the
  missing values pass through into the returned design matrices. However,
  this last option is not yet implemented, because of the lack of any
  standard way to represent missing values in arbitrary numpy matrices;
  we're hoping numpy will get this sorted out before we standardize on
  anything ourselves.
  
  You can control how patsy handles missing data through the ``NA_action=``
  argument to functions like :func:`build_design_matrices` and
  :func:`dmatrix`. If all you want to do is to choose between ``drop`` and
  ``raise`` behaviour, you can pass one of those strings as the
  ``NA_action=`` argument directly. If you want more fine-grained control
  over how missing values are detected and handled, then you can create an
  instance of this class, or your own object that implements the same
  interface, and pass that as the ``NA_action=`` argument instead.
class_docstr_tok: ["An",":","class",":","`","NAAction","`","object","defines","a","strategy","for","handling","missing","data",".","``","NA","''","is","short","for","``","Not","Available","''",",","and","is","used","to","refer","to","any","value","which","is","somehow","unmeasured","or","unavailable",".","In","the","long","run",",","it","is","devoutly","hoped","that","numpy","will","gain","first-class","missing","value","support",".","Until","then",",","we","work","around","this","lack","as","best","we","'re","able",".","There","are","two","parts","to","this",":","First",",","we","have","to","determine","what","counts","as","missing","data",".","For","numerical","data",",","the","default","is","to","treat","NaN","values","(","e.g.",",","``","numpy.nan","``",")","as","missing",".","For","categorical","data",",","the","default","is","to","treat","NaN","values",",","and","also","the","Python","object","None",",","as","missing",".","(","This","is","consistent","with","how","pandas","does","things",",","so","if","you","'re","already","using","None\/NaN","to","mark","missing","data","in","your","pandas","DataFrames",",","you","'re","good","to","go",".",")","Second",",","we","have","to","decide","what","to","do","with","any","missing","data","when","we","encounter","it",".","One","option","is","to","simply","discard","any","rows","which","contain","missing","data","from","our","design","matrices","(","``","drop","``",")",".","Another","option","is","to","raise","an","error","(","``","raise","``",")",".","A","third","option","would","be","to","simply","let","the","missing","values","pass","through","into","the","returned","design","matrices",".","However",",","this","last","option","is","not","yet","implemented",",","because","of","the","lack","of","any","standard","way","to","represent","missing","values","in","arbitrary","numpy","matrices",";","we","'re","hoping","numpy","will","get","this","sorted","out","before","we","standardize","on","anything","ourselves",".","You","can","control","how","patsy","handles","missing","data","through","the","``","NA_action=","``","argument","to","functions","like",":","func",":","`","build_design_matrices","`","and",":","func",":","`","dmatrix","`",".","If","all","you","want","to","do","is","to","choose","between","``","drop","``","and","``","raise","``","behaviour",",","you","can","pass","one","of","those","strings","as","the","``","NA_action=","``","argument","directly",".","If","you","want","more","fine-grained","control","over","how","missing","values","are","detected","and","handled",",","then","you","can","create","an","instance","of","this","class",",","or","your","own","object","that","implements","the","same","interface",",","and","pass","that","as","the","``","NA_action=","``","argument","instead","."]
docstr: The :class:`NAAction` constructor takes the following arguments:
  
  :arg on_NA: How to handle missing values. The default is ``"drop"``,
    which removes all rows from all matrices which contain any missing
    values. Also available is ``"raise"``, which raises an exception
    when any missing values are encountered.
  :arg NA_types: Which rules are used to identify missing values, as a
    list of strings. Allowed values are:
  
    * ``"None"``: treat the ``None`` object as missing in categorical
      data.
    * ``"NaN"``: treat floating point NaN values as missing in
      categorical and numerical data.
  
  .. versionadded:: 0.2.0
docstr_tok: ["The",":","class",":","`","NAAction","`","constructor","takes","the","following","arguments",":",":","arg","on_NA",":","How","to","handle","missing","values",".","The","default","is","``","``","drop","''","``",",","which","removes","all","rows","from","all","matrices","which","contain","any","missing","values",".","Also","available","is","``","``","raise","''","``",",","which","raises","an","exception","when","any","missing","values","are","encountered",".",":","arg","NA_types",":","Which","rules","are","used","to","identify","missing","values",",","as","a","list","of","strings",".","Allowed","values","are",":","*","``","``","None","''","``",":","treat","the","``","None","``","object","as","missing","in","categorical","data",".","*","``","``","NaN","''","``",":","treat","floating","point","NaN","values","as","missing","in","categorical","and","numerical","data",".","..","versionadded",":",":","0.2.0"]
code: def __init__(self, on_NA="drop", NA_types=["None", "NaN"]):
      """The :class:`NAAction` constructor takes the following arguments:
  
      :arg on_NA: How to handle missing values. The default is ``"drop"``,
        which removes all rows from all matrices which contain any missing
        values. Also available is ``"raise"``, which raises an exception
        when any missing values are encountered.
      :arg NA_types: Which rules are used to identify missing values, as a
        list of strings. Allowed values are:
  
        * ``"None"``: treat the ``None`` object as missing in categorical
          data.
        * ``"NaN"``: treat floating point NaN values as missing in
          categorical and numerical data.
  
      .. versionadded:: 0.2.0
      """
      self.on_NA = on_NA
      if self.on_NA not in _valid_NA_responses:
          raise ValueError(
              "invalid on_NA action %r "
              "(should be one of %s)"
              % (on_NA, _desc_options(_valid_NA_responses))
          )
      if isinstance(NA_types, str):
          raise ValueError("NA_types should be a list of strings")
      self.NA_types = tuple(NA_types)
      for NA_type in self.NA_types:
          if NA_type not in _valid_NA_types:
              raise ValueError(
                  "invalid NA_type %r "
                  "(should be one of %s)"
                  % (NA_type, _desc_options(_valid_NA_types))
              )
  
file_path: patsy/patsy/missing.py
imports: import numpy
  from patsy import PatsyError
  from patsy.util import safe_isnan, safe_scalar_isnan, no_pickling, assert_no_pickling
label_desc: Use image node_id 1 to create a new NAAction object from inherited base classes: object with example: obj = NAAction(on_NA, NA_types)