Re: frequency of values in a field

2011-02-09 Thread noydb
On Feb 9, 3:28 pm, Ethan Furman wrote: > noydb wrote: > >  > Paul Rubin wrote: > > > > > > >> The Decimal module is pretty slow but is conceptually probably the right > >> way to do this.  With just 50k records it shouldn't be too bad.  With > >> more records you might look for a faster way. > > >

Re: frequency of values in a field

2011-02-09 Thread noydb
On Feb 9, 3:08 pm, Josh English wrote: > On Wednesday, February 9, 2011 10:34:12 AM UTC-8, noydb wrote: > > > How do you add all the records in the particular field of interest > > into long_list? > > Sorry to be unclear. In both cases I was tossing out pseudo-code, as I am not > familiar with th

Re: frequency of values in a field

2011-02-09 Thread Ethan Furman
noydb wrote: > Paul Rubin wrote: The Decimal module is pretty slow but is conceptually probably the right way to do this. With just 50k records it shouldn't be too bad. With more records you might look for a faster way. from decimal import Decimal as D from collections import defaultdi

Re: frequency of values in a field

2011-02-09 Thread Josh English
On Wednesday, February 9, 2011 10:34:12 AM UTC-8, noydb wrote: > > How do you add all the records in the particular field of interest > into long_list? Sorry to be unclear. In both cases I was tossing out pseudo-code, as I am not familiar with the arggisscripting module. long_list is a list wit

RE: frequency of values in a field

2011-02-09 Thread Andreas Tawn
> How do you add all the records in the particular field of interest > into long_list? >From earlier in the thread you did... import arcgisscripting # Create the geoprocessor object gp = arcgisscripting.create() records_list = [] cur = gp.SearchCursor(dbfTable) row = cur.Next() while row: valu

Re: frequency of values in a field

2011-02-09 Thread Paul Rubin
noydb writes: >> counts = {} >> for thing in long_list: >>   key = make_key(thing) >>   if key in counts: >>     counts[key] += 1 >>   else: >>     counts[key] = 1 counts = {} for thing i long_list: key = make_key(thing) counts[key] = 1 + counts.get(key, 0) > How do you add all the records i

Re: frequency of values in a field

2011-02-09 Thread noydb
On Feb 9, 1:21 pm, Josh English wrote: > On Wednesday, February 9, 2011 9:52:27 AM UTC-8, noydb wrote: > > > So it seems the idea is to add all the records in the particular field > > of interest into a list (record).  How does one do this in pure > > Python? > > Normally in my work with gis/arcgi

Re: frequency of values in a field

2011-02-09 Thread Josh English
On Wednesday, February 9, 2011 9:52:27 AM UTC-8, noydb wrote: > > So it seems the idea is to add all the records in the particular field > of interest into a list (record). How does one do this in pure > Python? > Normally in my work with gis/arcgis sw, I would do a search cursor on > the DBF fi

Re: frequency of values in a field

2011-02-09 Thread noydb
> > The Decimal module is pretty slow but is conceptually probably the right > way to do this.  With just 50k records it shouldn't be too bad.  With > more records you might look for a faster way. > >     from decimal import Decimal as D >     from collections import defaultdict > >     records = [

Re: frequency of values in a field

2011-02-08 Thread Vlastimil Brom
2011/2/8, Paul Rubin : > noydb writes: >> I am looking for ways to go about capturing the frequency of unique >> values in one field in a dbf table which contains ~50k records. The >> values are numbers with atleast 5 digits to the right of the decimal, >> but I want the frequency of values to on

Re: frequency of values in a field

2011-02-08 Thread Paul Rubin
noydb writes: > I am looking for ways to go about capturing the frequency of unique > values in one field in a dbf table which contains ~50k records. The > values are numbers with atleast 5 digits to the right of the decimal, > but I want the frequency of values to only 2 decimal places. I do >

Re: frequency of values in a field

2011-02-08 Thread Josh English
You could try a collections.defaultdict object with an integer as the startup value: counts = collections.defaultdict(int) for thing in long_list: counts[get_last_two_digits(thing)] += 1 This assumes get_last_two_digits is the function that provides the key you want to count by. I'm not sure

frequency of values in a field

2011-02-08 Thread noydb
I am looking for ways to go about capturing the frequency of unique values in one field in a dbf table which contains ~50k records. The values are numbers with atleast 5 digits to the right of the decimal, but I want the frequency of values to only 2 decimal places. I do have a method to do this