def merge_field_into(s1, key, value):
  """Create a new namedtuple that is a copy of s1 with the key,value replaced."""
  dd = {}
  for k in s1._fields:
    dd[k] = getattr(s1, k)
  dd[key] = value
  return s1.__class__(**dd)