1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
5
>The Column class</TITLE
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
10
TITLE="PyTables User's Guide"
11
HREF="index.html"><LINK
13
TITLE="Library Reference"
14
HREF="c1381.html"><LINK
16
TITLE="The Description class"
17
HREF="x3623.html"><LINK
21
HREF="x3869.html"></HEAD
32
SUMMARY="Header navigation table"
44
> User's Guide: Hierarchical datasets in Python - Release 1.3.2</TH
60
>Chapter 4. Library Reference</TD
87
NAME="ColumnClassDescr"
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.
100
NAME="subsection4.9.1"
117
CLASS="computeroutput"
129
>The name of the associated
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
143
CLASS="computeroutput"
154
>The data type of the column.
163
>The shape of the column.
172
>The associated <SAMP
173
CLASS="computeroutput"
177
HREF="x4983.html#IndexClassDescr"
181
CLASS="computeroutput"
183
> if does not exist).
192
>Whether the index is dirty or not
204
NAME="subsection4.9.2"
215
NAME="subsubsection4.9.2.1"
222
NAME="createIndexColumnDescr"
226
CLASS="computeroutput"
229
HREF="x4983.html#IndexClassDescr"
240
NAME="subsubsection4.9.2.2"
247
NAME="reIndexColumnDescr"
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
261
NAME="subsubsection4.9.2.3"
264
>reIndexDirty()</SPAN
268
NAME="reIndexDirtyColumnDescr"
271
>Recompute the existing index only if it is dirty. This
272
can be useful when you have set the <SAMP
273
CLASS="computeroutput"
276
parameter to 0 in <SAMP
277
CLASS="computeroutput"
281
HREF="x4983.html#IndexPropsInitDescr"
284
table and want to update the column's index after a
285
invalidating index operation
287
CLASS="computeroutput"
288
>Table.removeRows</SAMP
297
NAME="subsubsection4.9.2.4"
304
NAME="removeIndexColumnDescr"
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
311
CLASS="computeroutput"
314
HREF="x3737.html#createIndexColumnDescr"
325
NAME="subsection4.9.3"
336
NAME="subsubsection4.9.3.1"
339
>__getitem__(key)</SPAN
343
NAME="Column.__getitem__"
346
>Returns a column element or slice. It takes different
347
actions depending on the type of the <SPAN
366
CLASS="computeroutput"
373
element in the column is returned as a scalar object
375
CLASS="computeroutput"
377
> object, depending on
388
CLASS="computeroutput"
395
determined by this slice is returned as a
397
CLASS="computeroutput"
408
> print "Column handlers:"
409
for name in table.colnames:
410
print table.cols[name]
412
print "Some selections:"
413
print "Select table.cols.name[1]-->", table.cols.name[1]
414
print "Select table.cols.name[1:2]-->", table.cols.name[1:2]
415
print "Select table.cols.lati[1:3]-->", table.cols.lati[1:3]
416
print "Select table.cols.pressure[:]-->", table.cols.pressure[:]
417
print "Select table.cols['temperature'][:]-->", table.cols['temperature'][:]
420
and the output of this for a certain arbitrary table is:
423
> 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)
431
Select table.cols.name[1]--> Particle: 11
432
Select table.cols.name[1:2]--> ['Particle: 11']
433
Select table.cols.lati[1:3]--> [[11 12]
435
Select table.cols.pressure[:]--> [ 90. 110. 132.]
436
Select table.cols['temperature'][:]--> [ 100. 121. 144.]
440
CLASS="computeroutput"
441
>examples/table2.py</SAMP
451
NAME="subsubsection4.9.3.2"
452
>4.9.3.2. __setitem__(key, value)</A
455
NAME="Column.__setitem__"
458
>It takes different actions depending on the
460
CLASS="computeroutput"
473
CLASS="computeroutput"
480
element in the column is set to
493
> must be a scalar or
495
CLASS="computeroutput"
498
CLASS="computeroutput"
501
depending on column's shape.
511
CLASS="computeroutput"
540
CLASS="computeroutput"
543
CLASS="computeroutput"
554
> # Modify row 1
555
table.cols.col1[1] = -1
556
# Modify rows 1 and 3
557
table.cols.col1[1::2] = [2,3]
560
>Which is equivalent to:</P
563
> # 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"])
577
SUMMARY="Footer navigation table"
b'\\ No newline at end of file'