# libpysal.weights.remap_ids

libpysal.weights.remap_ids(w, old2new, id_order=[], **kwargs)

  Remaps the IDs in a spatial weights object.

  Parameters:
    w `W`

      Spatial weights object

    old2new `dictionary`

      Dictionary where the keys are the IDs in w (i.e. “old IDs”) and the values are the IDs to replace them (i.e. “new IDs”)

    id_order `python:list`

      An ordered list of new IDs, which defines the order of observations when iterating over W. If not set then the id_order in w will be used.

    **kwargs `keyword` `arguments`

      optional arguments for `pysal.weights.W`

  Returns:
    implicit `W`

      Spatial weights object with new IDs

  Examples

      >>> from libpysal.weights import lat2W
      >>> w = lat2W(3,2)
      >>> w.id_order
      [0, 1, 2, 3, 4, 5]
      >>> w.neighbors[0]
      [2, 1]
      >>> old_to_new = {0:'a', 1:'b', 2:'c', 3:'d', 4:'e', 5:'f'}
      >>> w_new = remap_ids(w, old_to_new)
      >>> w_new.id_order
      ['a', 'b', 'c', 'd', 'e', 'f']
      >>> w_new.neighbors['a']
      ['c', 'b']