Skip to content

DOC: show disallowed eval syntax #4922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 22, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions doc/source/enhancingperf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,42 @@ engine in addition to some extensions available only in pandas.
The larger the frame and the larger the expression the more speedup you will
see from using :func:`~pandas.eval`.

Supported Syntax
~~~~~~~~~~~~~~~~

These operations are supported by :func:`~pandas.eval`:

- Arithmetic operations except for the left shift (``<<``) and right shift
(``>>``) operators, e.g., ``df + 2 * pi / s ** 4 % 42 - the_golden_ratio``
- Comparison operations, e.g., ``2 < df < df2``
- Boolean operations, e.g., ``df < df2 and df3 < df4 or not df_bool``
- ``list`` and ``tuple`` literals, e.g., ``[1, 2]`` or ``(1, 2)``
- Attribute access, e.g., ``df.a``
- Subscript expressions, e.g., ``df[0]``
- Simple variable evaluation, e.g., ``pd.eval('df')`` (this is not very useful)

This Python syntax is **not** allowed:

* Expressions

- Function calls
- ``is``/``is not`` operations
- ``if`` expressions
- ``lambda`` expressions
- ``list``/``set``/``dict`` comprehensions
- Literal ``dict`` and ``set`` expressions
- ``yield`` expressions
- Generator expressions
- Boolean expressions consisting of only scalar values

* Statements

- Neither `simple <http://docs.python.org/2/reference/simple_stmts.html>`__
nor `compound <http://docs.python.org/2/reference/compound_stmts.html>`__
statements are allowed. This includes things like ``for``, ``while``, and
``if``.



:func:`~pandas.eval` Examples
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down