|
From: Francesc A. <fa...@py...> - 2010-04-28 19:12:04
|
A Wednesday 28 April 2010 20:22:52 Ernesto escrigué:
> Hi Francesc, thank you for your reply.
>
> > The first column contains an integer. Now I'd like to sort my table
> > according to numbers of the first column. Is there a way to perform this
> > action?
> >
> > Yes. The simplest way is by setting the `sortby` parameter to true in
> > the `Table.copy()` method. This triggers an on-disk sorting operation,
> > so you don't have to be afraid of your available memory. You will need
> > the Pro version for getting this capability.
>
> It means that I can sort a table using the Pro version only. No other
> solutions are available?
I haven't said that no other solutions are available. Only that the Pro venue
is the simplest (and certainly a powerful one ;-) If you want to go Pro, you
may want to use plain NumPy for doing this.
> Working with my simple table I found a strange
> behaviour that probably is due to my limited experience with pytables. The
> description of the table is:
> /newgroup/table (Table(729036,), shuffle, zlib(1)) 'A table'
> description := {
> "position": Int32Col(shape=(), dflt=0, pos=0),
> "read": StringCol(itemsize=1, shape=(), dflt='', pos=1),
> "qual": Int32Col(shape=(), dflt=0, pos=2),
> "strand": StringCol(itemsize=1, shape=(), dflt='', pos=3)}
> byteorder := 'little'
> chunkshape := (819,)
> Next I iterate over a subset using the command:
> for row in table.where('(qual > 1) & (qual < 10)'):
> print row
> It works correctly and I get expected results.
> Then I use the following command:
> results=[row for row in table.where('(qual > 1) & (qual < 10)')]
> it works but I get a list containing the same value.
> I report the first five rows obtained using both procedures:
> - procedure 1:
> (167809, 'C', 8, '-')
> (167810, 'G', 9, '-')
> (167812, 'C', 5, '-')
> (167823, 'T', 9, '-')
> (1015856, 'G', 5, '-')
> - procedure 2:
> [(1041269, 'G', 39, '-'), (1041269, 'G', 39, '-'), (1041269, 'G', 39, '-'),
> (1041269, 'G', 39, '-'), (1041269, 'G', 39, '-')]
>
> Where is the error?
No, it is not, but it is a common pitfall for beginners. See:
http://sourceforge.net/mailarchive/forum.php?thread_name=200905141759.16731.faltet%40pytables.org&forum_name=pytables-
users
Anyway, I've decided to avoid this behaviour in 2.2 series. For details, see:
http://pytables.org/trac/ticket/252
Ciao,
--
Francesc Alted
|