title: How to make a function accept and output a Dataframe series?
body: <p>I am trying to sort a Dataframe along one column, using a callable. Pandas docs says the callable needs to expect a series and return a series with the same shape. I am using this below function, adapted from two others, that takes a list of Hex colors and sorts in a specific way.</p>
  <pre><code>result = pd.DataFrame(frame)
  
  def step (hexrgb, repetitions=1):
      r, g, b = (int(hexrgb[i:i+2], 16) / 255.0 for i in range(0,5,2))
      colorsys.rgb_to_hsv(r, g, b)
      lum = math.sqrt( .241 * r + .691 * g + .068 * b )
      h, s, v = colorsys.rgb_to_hsv(r,g,b)
      h2 = int(h * repetitions)
      lum2 = int(lum * repetitions)
      v2 = int(v * repetitions)
      return (colorsys.hsv_to_rgb(h2, lum, v2))
  
  
  print(result.sort_values(by=['First Color'], key=step))
  </code></pre>
  <p>There may be any number of errors here but the main thing, it seems, is getting the function to accept and output a series:</p>
  <pre><code>0    c89664
  1    e1c8af
  2    c8c896
  3    c8c8af
  4    e1af96
  </code></pre>
  <p>Any help appreciated as I am new to this.</p>