Skip to Content

en PL/Python

  1. CREATE OR REPLACE FUNCTION py_numeric_median(_numeric) RETURNS text AS
  2. $$
  3. import numpy
  4. # t = eval(args[0].replace("{","[").replace("}","]"))
  5. t = args[0].replace("{","").replace("}","").split(",")
  6.  
  7. t1 = []
  8. for v in t:
  9. t1.append(float(v))
  10. return numpy.median(t1)
  11. $$ LANGUAGE 'plpythonu';