code: def move_point_cat(point, ipoint, to_clust, from_clust, cl_attr_freq,
                     membship, centroids):
      
      membship[to_clust, ipoint] = 1
      membship[from_clust, ipoint] = 0
      # Update frequencies of attributes in cluster.
      for iattr, curattr in enumerate(point):
          to_attr_counts = cl_attr_freq[to_clust][iattr]
          from_attr_counts = cl_attr_freq[from_clust][iattr]
  
          # Increment the attribute count for the new "to" cluster
          to_attr_counts[curattr] += 1
  
          current_attribute_value_freq = to_attr_counts[curattr]
          current_centroid_value = centroids[to_clust][iattr]
          current_centroid_freq = to_attr_counts[current_centroid_value]
          if current_centroid_freq < current_attribute_value_freq:
              # We have incremented this value to the new mode. Update the centroid.
              centroids[to_clust][iattr] = curattr
  
          # Decrement the attribute count for the old "from" cluster
          from_attr_counts[curattr] -= 1
  
          old_centroid_value = centroids[from_clust][iattr]
          if old_centroid_value == curattr:
              # We have just removed a count from the old centroid value. We need to
              # recalculate the centroid as it may no longer be the maximum
              centroids[from_clust][iattr] = get_max_value_key(from_attr_counts)
  
      return cl_attr_freq, membship, centroids
docs: Move point between clusters, categorical attributes.