MCPcopy Index your code
hub / github.com/PyTables/PyTables / where

Method where

tables/table.py:1479–1575  ·  view source on GitHub ↗

r"""Iterate over values fulfilling a condition. This method returns a Row iterator (see :ref:`RowClassDescr`) which only selects rows in the table that satisfy the given condition (an expression-like string). The condvars mapping may be used to define the variable n

(
        self,
        condition: str,
        condvars: dict[str, Column | np.ndarray] | None = None,
        start: str | None = None,
        stop: str | None = None,
        step: str | None = None,
    )

Source from the content-addressed store, hash-verified

1477 return frozenset(idxcols)
1478
1479 def where(
1480 self,
1481 condition: str,
1482 condvars: dict[str, Column | np.ndarray] | None = None,
1483 start: str | None = None,
1484 stop: str | None = None,
1485 step: str | None = None,
1486 ) -> Iterator[tableextension.Row]:
1487 r"""Iterate over values fulfilling a condition.
1488
1489 This method returns a Row iterator (see :ref:`RowClassDescr`) which
1490 only selects rows in the table that satisfy the given condition (an
1491 expression-like string).
1492
1493 The condvars mapping may be used to define the variable names appearing
1494 in the condition. condvars should consist of identifier-like strings
1495 pointing to Column (see :ref:`ColumnClassDescr`) instances *of this
1496 table*, or to other values (which will be converted to arrays). A
1497 default set of condition variables is provided where each top-level,
1498 non-nested column with an identifier-like name appears. Variables in
1499 condvars override the default ones.
1500
1501 When condvars is not provided or None, the current local and global
1502 namespace is sought instead of condvars. The previous mechanism is
1503 mostly intended for interactive usage. To disable it, just specify a
1504 (maybe empty) mapping as condvars.
1505
1506 If a range is supplied (by setting some of the start, stop or step
1507 parameters), only the rows in that range and fulfilling the condition
1508 are used. The meaning of the start, stop and step parameters is the
1509 same as for Python slices.
1510
1511 When possible, indexed columns participating in the condition will be
1512 used to speed up the search. It is recommended that you place the
1513 indexed columns as left and out in the condition as possible. Anyway,
1514 this method has always better performance than regular Python
1515 selections on the table.
1516
1517 You can mix this method with regular Python selections in order to
1518 support even more complex queries. It is strongly recommended that you
1519 pass the most restrictive condition as the parameter to this method if
1520 you want to achieve maximum performance.
1521
1522 .. warning::
1523
1524 When in the middle of a table row iterator, you should not
1525 use methods that can change the number of rows in the table
1526 (like :meth:`Table.append` or :meth:`Table.remove_rows`) or
1527 unexpected errors will happen.
1528
1529 Examples
1530 --------
1531 ::
1532
1533 passvalues = [ row['col3'] for row in
1534 table.where('(col1 > 0) & (col2 <= 20)', step=5)
1535 if your_function(row['col2']) ]
1536 print("Values that pass the cuts:", passvalues)

Callers 15

_fancy_selectionMethod · 0.80
where_with_localsMethod · 0.80
where_with_globalsMethod · 0.80
where_whith_localsMethod · 0.80
test01d_readTableMethod · 0.80
test01e_readTableMethod · 0.80
test01f_readTableMethod · 0.80
test07Method · 0.80
test09Method · 0.80
test00_sameMethod · 0.80
test01_compatibleMethod · 0.80
test02_lessPreciseMethod · 0.80

Calls 1

_whereMethod · 0.95

Tested by 15

where_with_localsMethod · 0.64
where_with_globalsMethod · 0.64
where_whith_localsMethod · 0.64
test01d_readTableMethod · 0.64
test01e_readTableMethod · 0.64
test01f_readTableMethod · 0.64
test07Method · 0.64
test09Method · 0.64
test00_sameMethod · 0.64
test01_compatibleMethod · 0.64
test02_lessPreciseMethod · 0.64
test_gh260Method · 0.64