Skip to content
Open
Show file tree
Hide file tree
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
33 changes: 33 additions & 0 deletions doc/source/reference/api.typing.Expression.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
pandas.api.typing.Expression
============================

.. currentmodule:: pandas.api.typing

.. autoclass:: Expression
:members:
:undoc-members:
:show-inheritance:

**Description**

An ``Expression`` represents a symbolic reference to a DataFrame column.
It can be used inside functions like ``DataFrame.assign`` or ``DataFrame.loc`` to
refer to columns in a declarative way.

Example
-------

.. code-block:: python

import pandas as pd

df = pd.DataFrame({"a": [1, 2, 3]})
df.assign(b=pd.col("a") + 5)

**Supported Operations**

- Arithmetic: ``+``, ``-``, ``*``, ``/``
- Comparison: ``<``, ``>``, ``==``, ``!=``
- Universal functions (ufuncs): can be applied directly
- Series accessors: ``.dt``, ``.str``, ``.cat``
- Series methods: ``.sum()``, ``.mean()``, ``.astype()``, etc.
2 changes: 2 additions & 0 deletions doc/source/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ to be stable.
testing
missing_value
aliases
api.typing.Expression


.. This is to prevent warnings in the doc build. We don't want to encourage
.. these methods.
Expand Down
Loading