~ubuntu-branches/ubuntu/natty/pytables/natty-updates

« back to all changes in this revision

Viewing changes to doc/html/x3737.html

  • Committer: Bazaar Package Importer
  • Author(s): Alexandre Fayolle
  • Date: 2006-06-28 10:45:03 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20060628104503-cc251q5o5j3e2k10
  * Fixed call to pyversions in debian/rules which failed on recent versions 
    of pyversions
  * Fixed clean rule in debian/rules which left the stamp files behind
  * Acknowledge NMU
  * Added Alexandre Fayolle to uploaders

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
 
2
<HTML
 
3
><HEAD
 
4
><TITLE
 
5
>The Column class</TITLE
 
6
><META
 
7
NAME="GENERATOR"
 
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
 
9
REL="HOME"
 
10
TITLE="PyTables User's Guide"
 
11
HREF="index.html"><LINK
 
12
REL="UP"
 
13
TITLE="Library Reference"
 
14
HREF="c1381.html"><LINK
 
15
REL="PREVIOUS"
 
16
TITLE="The Description class"
 
17
HREF="x3623.html"><LINK
 
18
REL="NEXT"
 
19
TITLE="The Array
 
20
            class"
 
21
HREF="x3869.html"></HEAD
 
22
><BODY
 
23
CLASS="sect1"
 
24
BGCOLOR="#FFFFFF"
 
25
TEXT="#000000"
 
26
LINK="#0000FF"
 
27
VLINK="#840084"
 
28
ALINK="#0000FF"
 
29
><DIV
 
30
CLASS="NAVHEADER"
 
31
><TABLE
 
32
SUMMARY="Header navigation table"
 
33
WIDTH="100%"
 
34
BORDER="0"
 
35
CELLPADDING="0"
 
36
CELLSPACING="0"
 
37
><TR
 
38
><TH
 
39
COLSPAN="3"
 
40
ALIGN="center"
 
41
><SPAN
 
42
CLASS="markup"
 
43
>PyTables</SPAN
 
44
> User's Guide: Hierarchical datasets in Python - Release 1.3.2</TH
 
45
></TR
 
46
><TR
 
47
><TD
 
48
WIDTH="10%"
 
49
ALIGN="left"
 
50
VALIGN="bottom"
 
51
><A
 
52
HREF="x3623.html"
 
53
ACCESSKEY="P"
 
54
>Prev</A
 
55
></TD
 
56
><TD
 
57
WIDTH="80%"
 
58
ALIGN="center"
 
59
VALIGN="bottom"
 
60
>Chapter 4. Library Reference</TD
 
61
><TD
 
62
WIDTH="10%"
 
63
ALIGN="right"
 
64
VALIGN="bottom"
 
65
><A
 
66
HREF="x3869.html"
 
67
ACCESSKEY="N"
 
68
>Next</A
 
69
></TD
 
70
></TR
 
71
></TABLE
 
72
><HR
 
73
ALIGN="LEFT"
 
74
WIDTH="100%"></DIV
 
75
><DIV
 
76
CLASS="sect1"
 
77
><H1
 
78
CLASS="sect1"
 
79
><A
 
80
NAME="section4.9"
 
81
>4.9. The <SPAN
 
82
CLASS="markup"
 
83
>Column</SPAN
 
84
> class</A
 
85
></H1
 
86
><A
 
87
NAME="ColumnClassDescr"
 
88
></A
 
89
><P
 
90
>Each instance of this class is associated with one column
 
91
            of every table. These instances are mainly used to fetch and
 
92
            set actual data from the table columns, but there are a few
 
93
            other associated methods to deal with indexes.
 
94
          </P
 
95
><DIV
 
96
CLASS="sect2"
 
97
><H2
 
98
CLASS="sect2"
 
99
><A
 
100
NAME="subsection4.9.1"
 
101
>4.9.1. <SPAN
 
102
CLASS="markup"
 
103
>Column</SPAN
 
104
> instance
 
105
              variables</A
 
106
></H2
 
107
><DIV
 
108
CLASS="glosslist"
 
109
><DL
 
110
><DT
 
111
><B
 
112
>table</B
 
113
></DT
 
114
><DD
 
115
><P
 
116
>The parent <SAMP
 
117
CLASS="computeroutput"
 
118
>Table</SAMP
 
119
>
 
120
                instance.
 
121
              </P
 
122
></DD
 
123
><DT
 
124
><B
 
125
>name</B
 
126
></DT
 
127
><DD
 
128
><P
 
129
>The name of the associated
 
130
                column.
 
131
              </P
 
132
></DD
 
133
><DT
 
134
><B
 
135
>pathname</B
 
136
></DT
 
137
><DD
 
138
><P
 
139
>The complete pathname of the
 
140
                associated column. This is mainly useful in nested
 
141
                columns; for non-nested ones this value is the same a
 
142
                <SAMP
 
143
CLASS="computeroutput"
 
144
>name</SAMP
 
145
>.
 
146
              </P
 
147
></DD
 
148
><DT
 
149
><B
 
150
>type</B
 
151
></DT
 
152
><DD
 
153
><P
 
154
>The data type of the column.
 
155
              </P
 
156
></DD
 
157
><DT
 
158
><B
 
159
>shape</B
 
160
></DT
 
161
><DD
 
162
><P
 
163
>The shape of the column.
 
164
              </P
 
165
></DD
 
166
><DT
 
167
><B
 
168
>index</B
 
169
></DT
 
170
><DD
 
171
><P
 
172
>The associated <SAMP
 
173
CLASS="computeroutput"
 
174
>Index</SAMP
 
175
>
 
176
                object (see <A
 
177
HREF="x4983.html#IndexClassDescr"
 
178
>4.17.3</A
 
179
>) to this
 
180
                column (<SAMP
 
181
CLASS="computeroutput"
 
182
>None</SAMP
 
183
> if does not exist).
 
184
              </P
 
185
></DD
 
186
><DT
 
187
><B
 
188
>dirty</B
 
189
></DT
 
190
><DD
 
191
><P
 
192
>Whether the index is dirty or not
 
193
                (property).
 
194
              </P
 
195
></DD
 
196
></DL
 
197
></DIV
 
198
></DIV
 
199
><DIV
 
200
CLASS="sect2"
 
201
><H2
 
202
CLASS="sect2"
 
203
><A
 
204
NAME="subsection4.9.2"
 
205
>4.9.2. <SPAN
 
206
CLASS="markup"
 
207
>Column</SPAN
 
208
> methods</A
 
209
></H2
 
210
><DIV
 
211
CLASS="sect3"
 
212
><H3
 
213
CLASS="sect3"
 
214
><A
 
215
NAME="subsubsection4.9.2.1"
 
216
>4.9.2.1. <SPAN
 
217
CLASS="markup"
 
218
>createIndex()</SPAN
 
219
></A
 
220
></H3
 
221
><A
 
222
NAME="createIndexColumnDescr"
 
223
></A
 
224
><P
 
225
>Create an <SAMP
 
226
CLASS="computeroutput"
 
227
>Index</SAMP
 
228
> (see <A
 
229
HREF="x4983.html#IndexClassDescr"
 
230
>4.17.3</A
 
231
>) object for this
 
232
                column.
 
233
              </P
 
234
></DIV
 
235
><DIV
 
236
CLASS="sect3"
 
237
><H3
 
238
CLASS="sect3"
 
239
><A
 
240
NAME="subsubsection4.9.2.2"
 
241
>4.9.2.2. <SPAN
 
242
CLASS="markup"
 
243
>reIndex()</SPAN
 
244
></A
 
245
></H3
 
246
><A
 
247
NAME="reIndexColumnDescr"
 
248
></A
 
249
><P
 
250
>Recompute the index associated with this column. This
 
251
                can be useful when you suspect that, for any reason, the
 
252
                index information is no longer valid and want to rebuild
 
253
                it.
 
254
              </P
 
255
></DIV
 
256
><DIV
 
257
CLASS="sect3"
 
258
><H3
 
259
CLASS="sect3"
 
260
><A
 
261
NAME="subsubsection4.9.2.3"
 
262
>4.9.2.3. <SPAN
 
263
CLASS="markup"
 
264
>reIndexDirty()</SPAN
 
265
></A
 
266
></H3
 
267
><A
 
268
NAME="reIndexDirtyColumnDescr"
 
269
></A
 
270
><P
 
271
>Recompute the existing index only if it is dirty. This
 
272
                can be useful when you have set the <SAMP
 
273
CLASS="computeroutput"
 
274
>reindex</SAMP
 
275
>
 
276
                parameter to 0 in <SAMP
 
277
CLASS="computeroutput"
 
278
>IndexProps</SAMP
 
279
> constructor
 
280
                (see <A
 
281
HREF="x4983.html#IndexPropsInitDescr"
 
282
>4.17.2</A
 
283
>) for the
 
284
                table and want to update the column's index after a
 
285
                invalidating index operation
 
286
                (<SAMP
 
287
CLASS="computeroutput"
 
288
>Table.removeRows</SAMP
 
289
>, for example).
 
290
              </P
 
291
></DIV
 
292
><DIV
 
293
CLASS="sect3"
 
294
><H3
 
295
CLASS="sect3"
 
296
><A
 
297
NAME="subsubsection4.9.2.4"
 
298
>4.9.2.4. <SPAN
 
299
CLASS="markup"
 
300
>removeIndex()</SPAN
 
301
></A
 
302
></H3
 
303
><A
 
304
NAME="removeIndexColumnDescr"
 
305
></A
 
306
><P
 
307
>Delete the associated column's index. After doing that,
 
308
                you will loose the indexation information on
 
309
                disk. However, you can always re-create it using the
 
310
                <SAMP
 
311
CLASS="computeroutput"
 
312
>createIndex()</SAMP
 
313
> method (see <A
 
314
HREF="x3737.html#createIndexColumnDescr"
 
315
>4.9.2</A
 
316
>).
 
317
              </P
 
318
></DIV
 
319
></DIV
 
320
><DIV
 
321
CLASS="sect2"
 
322
><H2
 
323
CLASS="sect2"
 
324
><A
 
325
NAME="subsection4.9.3"
 
326
>4.9.3. <SPAN
 
327
CLASS="markup"
 
328
>Column</SPAN
 
329
> special methods</A
 
330
></H2
 
331
><DIV
 
332
CLASS="sect3"
 
333
><H3
 
334
CLASS="sect3"
 
335
><A
 
336
NAME="subsubsection4.9.3.1"
 
337
>4.9.3.1. <SPAN
 
338
CLASS="markup"
 
339
>__getitem__(key)</SPAN
 
340
></A
 
341
></H3
 
342
><A
 
343
NAME="Column.__getitem__"
 
344
></A
 
345
><P
 
346
>Returns a column element or slice. It takes different
 
347
                actions depending on the type of the <SPAN
 
348
CLASS="emphasis"
 
349
><I
 
350
CLASS="emphasis"
 
351
>key</I
 
352
></SPAN
 
353
>
 
354
                parameter:
 
355
              </P
 
356
><DIV
 
357
CLASS="glosslist"
 
358
><DL
 
359
><DT
 
360
><B
 
361
><SPAN
 
362
CLASS="markup"
 
363
>key</SPAN
 
364
> is an
 
365
                  <SAMP
 
366
CLASS="computeroutput"
 
367
>Integer</SAMP
 
368
></B
 
369
></DT
 
370
><DD
 
371
><P
 
372
>The corresponding
 
373
                  element in the column is returned as a scalar object
 
374
                  or as a <SAMP
 
375
CLASS="computeroutput"
 
376
>numarray</SAMP
 
377
> object, depending on
 
378
                  its shape.
 
379
                </P
 
380
></DD
 
381
><DT
 
382
><B
 
383
><SPAN
 
384
CLASS="markup"
 
385
>key</SPAN
 
386
> is a
 
387
                  <SAMP
 
388
CLASS="computeroutput"
 
389
>Slice</SAMP
 
390
></B
 
391
></DT
 
392
><DD
 
393
><P
 
394
>The row range
 
395
                  determined by this slice is returned as a
 
396
                  <SAMP
 
397
CLASS="computeroutput"
 
398
>numarray</SAMP
 
399
> object.
 
400
                </P
 
401
></DD
 
402
></DL
 
403
></DIV
 
404
><P
 
405
>Example of use:
 
406
                <PRE
 
407
CLASS="screen"
 
408
>&#13;print "Column handlers:"
 
409
for name in table.colnames:
 
410
    print table.cols[name]
 
411
print
 
412
print "Some selections:"
 
413
print "Select table.cols.name[1]--&#62;", table.cols.name[1]
 
414
print "Select table.cols.name[1:2]--&#62;", table.cols.name[1:2]
 
415
print "Select table.cols.lati[1:3]--&#62;", table.cols.lati[1:3]
 
416
print "Select table.cols.pressure[:]--&#62;", table.cols.pressure[:]
 
417
print "Select table.cols['temperature'][:]--&#62;", table.cols['temperature'][:]
 
418
                </PRE
 
419
>
 
420
                and the output of this for a certain arbitrary table is:
 
421
                <PRE
 
422
CLASS="screen"
 
423
>&#13;Column handlers:
 
424
/table.cols.name (Column(1,), CharType)
 
425
/table.cols.lati (Column(2,), Int32)
 
426
/table.cols.longi (Column(1,), Int32)
 
427
/table.cols.pressure (Column(1,), Float32)
 
428
/table.cols.temperature (Column(1,), Float64)
 
429
 
 
430
Some selections:
 
431
Select table.cols.name[1]--&#62; Particle:     11
 
432
Select table.cols.name[1:2]--&#62; ['Particle:     11']
 
433
Select table.cols.lati[1:3]--&#62; [[11 12]
 
434
 [12 13]]
 
435
Select table.cols.pressure[:]--&#62; [  90.  110.  132.]
 
436
Select table.cols['temperature'][:]--&#62; [ 100.  121.  144.]
 
437
                </PRE
 
438
>
 
439
                See the <SAMP
 
440
CLASS="computeroutput"
 
441
>examples/table2.py</SAMP
 
442
> for a more
 
443
                complete example.
 
444
              </P
 
445
></DIV
 
446
><DIV
 
447
CLASS="sect3"
 
448
><H3
 
449
CLASS="sect3"
 
450
><A
 
451
NAME="subsubsection4.9.3.2"
 
452
>4.9.3.2. __setitem__(key, value)</A
 
453
></H3
 
454
><A
 
455
NAME="Column.__setitem__"
 
456
></A
 
457
><P
 
458
>It takes different actions depending on the
 
459
                type of the <SAMP
 
460
CLASS="computeroutput"
 
461
>key</SAMP
 
462
> parameter:</P
 
463
><DIV
 
464
CLASS="glosslist"
 
465
><DL
 
466
><DT
 
467
><B
 
468
><SPAN
 
469
CLASS="markup"
 
470
>key</SPAN
 
471
> is an
 
472
                  <SAMP
 
473
CLASS="computeroutput"
 
474
>Integer</SAMP
 
475
></B
 
476
></DT
 
477
><DD
 
478
><P
 
479
>The corresponding
 
480
                  element in the column is set to
 
481
                  <SPAN
 
482
CLASS="emphasis"
 
483
><I
 
484
CLASS="emphasis"
 
485
>value</I
 
486
></SPAN
 
487
>. <SPAN
 
488
CLASS="emphasis"
 
489
><I
 
490
CLASS="emphasis"
 
491
>value</I
 
492
></SPAN
 
493
> must be a scalar or
 
494
                  <SAMP
 
495
CLASS="computeroutput"
 
496
>numarray</SAMP
 
497
>/<SAMP
 
498
CLASS="computeroutput"
 
499
>NumPy</SAMP
 
500
> object,
 
501
                  depending on column's shape.
 
502
                </P
 
503
></DD
 
504
><DT
 
505
><B
 
506
><SPAN
 
507
CLASS="markup"
 
508
>key</SPAN
 
509
> is a
 
510
                  <SAMP
 
511
CLASS="computeroutput"
 
512
>Slice</SAMP
 
513
></B
 
514
></DT
 
515
><DD
 
516
><P
 
517
>The row slice
 
518
                  determined by <SPAN
 
519
CLASS="emphasis"
 
520
><I
 
521
CLASS="emphasis"
 
522
>key</I
 
523
></SPAN
 
524
> is set to
 
525
                  <SPAN
 
526
CLASS="emphasis"
 
527
><I
 
528
CLASS="emphasis"
 
529
>value</I
 
530
></SPAN
 
531
>. <SPAN
 
532
CLASS="emphasis"
 
533
><I
 
534
CLASS="emphasis"
 
535
>value</I
 
536
></SPAN
 
537
> must be a list of
 
538
                  elements or a
 
539
                  <SAMP
 
540
CLASS="computeroutput"
 
541
>numarray</SAMP
 
542
>/<SAMP
 
543
CLASS="computeroutput"
 
544
>NumPy</SAMP
 
545
>.
 
546
                </P
 
547
></DD
 
548
></DL
 
549
></DIV
 
550
><P
 
551
>Example of use:</P
 
552
><PRE
 
553
CLASS="screen"
 
554
>&#13;          # Modify row 1
 
555
                table.cols.col1[1] = -1
 
556
                # Modify rows 1 and 3
 
557
                table.cols.col1[1::2] = [2,3]
 
558
              </PRE
 
559
><P
 
560
>Which is equivalent to:</P
 
561
><PRE
 
562
CLASS="screen"
 
563
>&#13;          # Modify row 1
 
564
                table.modifyColumns(start=1, columns=[[-1]], names=["col1"])
 
565
                # Modify rows 1 and 3
 
566
                columns = numarray.records.fromarrays([[2,3]], formats="i4")
 
567
                table.modifyColumns(start=1, step=2, columns=columns, names=["col1"])
 
568
              </PRE
 
569
></DIV
 
570
></DIV
 
571
></DIV
 
572
><DIV
 
573
CLASS="NAVFOOTER"
 
574
><HR
 
575
ALIGN="LEFT"
 
576
WIDTH="100%"><TABLE
 
577
SUMMARY="Footer navigation table"
 
578
WIDTH="100%"
 
579
BORDER="0"
 
580
CELLPADDING="0"
 
581
CELLSPACING="0"
 
582
><TR
 
583
><TD
 
584
WIDTH="33%"
 
585
ALIGN="left"
 
586
VALIGN="top"
 
587
><A
 
588
HREF="x3623.html"
 
589
ACCESSKEY="P"
 
590
>Prev</A
 
591
></TD
 
592
><TD
 
593
WIDTH="34%"
 
594
ALIGN="center"
 
595
VALIGN="top"
 
596
><A
 
597
HREF="index.html"
 
598
ACCESSKEY="H"
 
599
>Home</A
 
600
></TD
 
601
><TD
 
602
WIDTH="33%"
 
603
ALIGN="right"
 
604
VALIGN="top"
 
605
><A
 
606
HREF="x3869.html"
 
607
ACCESSKEY="N"
 
608
>Next</A
 
609
></TD
 
610
></TR
 
611
><TR
 
612
><TD
 
613
WIDTH="33%"
 
614
ALIGN="left"
 
615
VALIGN="top"
 
616
>The <SPAN
 
617
CLASS="markup"
 
618
>Description</SPAN
 
619
> class</TD
 
620
><TD
 
621
WIDTH="34%"
 
622
ALIGN="center"
 
623
VALIGN="top"
 
624
><A
 
625
HREF="c1381.html"
 
626
ACCESSKEY="U"
 
627
>Up</A
 
628
></TD
 
629
><TD
 
630
WIDTH="33%"
 
631
ALIGN="right"
 
632
VALIGN="top"
 
633
>The <SPAN
 
634
CLASS="markup"
 
635
>Array</SPAN
 
636
>
 
637
            class</TD
 
638
></TR
 
639
></TABLE
 
640
></DIV
 
641
></BODY
 
642
></HTML
 
643
>
 
 
b'\\ No newline at end of file'