def get_df_fingerprint(df, cols):
  """Fingerprint the order of select column values within a dataframe."""
  try:
    strs = [
      sha256(b"".join(map(lambda v: int(v).to_bytes(8, "big"), df[col]))).hexdigest()
      for col in cols
    ]
    return sha256(",".join(strs).encode("utf-8")).hexdigest()
  except ValueError:
    strs = [sha256(",".join(map(str, df[col])).encode("utf-8")).hexdigest() for col in cols]
    return sha256(",".join(strs).encode("utf-8")).hexdigest()
Fingerprint the order of select column values within a dataframe.
sourcecode/scoring/pandas_utils.py