title: pyspark index to unique values
body: <p>You need to assign an index to unique values.
  StringIndexer is inappropriate because it takes into account the frequency of the character.</p>
  <p>How function pandas.factorize</p>
  <p>Like this:</p>
  <pre><code>        activity_start activity_end       activity_start_code  activity_end_code
  0           Stage_0      Stage_3                    0                  0
  1           Stage_3      Stage_5                    1                  1
  2           Stage_5      Stage_2                    2                  2
  3           Stage_2      Stage_7                    3                  3
  4           Stage_7          end                    4                  4
  5           Stage_0      Stage_2                    0                  2
  6           Stage_2      Stage_4                    3                  5
  7           Stage_4      Stage_3                    5                  0
  8           Stage_3      Stage_8                    1                  6
  9           Stage_8          end                    6                  4
  43          Stage_0      Stage_2                    0                  2
  44          Stage_2      Stage_5                    3                  1
  45          Stage_5      Stage_7                    2                  3
  46          Stage_7          end                    4                  4
  457         Stage_2      Stage_3                    3                  0
  458         Stage_3      Stage_8                    1                  6
  459         Stage_8          end                    6                  4 
  </code></pre>