python - How do I access the row index in an agate Formula? -


using python's tabular data library agate want define compute formula, accesses row index. tried

agate.formula(agate.text(), lambda r: r.index()) 

but doesn't work, because row object not provide (row) index (unlike column object!). there way access row index inside formula?

(i need in order create new column values unique each row.)

this function __doc__:

must return valid value specified data type. :param cast: if :code:true, each return value cast specified\n :code:data_type ensure valid.

this offitial tutorial:

number_type = agate.number()  def five_year_total(row):     columns = ('2009', '2010', '2011', '2012', '2013')      return sum(tuple(row[c] c in columns)]  formula = agate.formula(number_type, five_year_total)  new_table = table.compute([     ('five_year_total', formula) ]) 

judging these two, datatype wrong, index() function returns object type int yours text(). try using 1 docks agate.number(). tutorials used http://agate.readthedocs.io/en/1.6.0/cookbook/excel.html#simple-formulas


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -