Skip to content

Commit d99d850

Browse files
committed
DOC: Add documentation for pandas.api.typing.Expression (#63084)
1 parent 415830f commit d99d850

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
pandas.api.typing.Expression
2+
============================
3+
4+
.. currentmodule:: pandas.api.typing
5+
6+
.. autoclass:: Expression
7+
:members:
8+
:undoc-members:
9+
:show-inheritance:
10+
11+
**Description**
12+
13+
An ``Expression`` represents a symbolic reference to a DataFrame column.
14+
It can be used inside functions like ``DataFrame.assign`` or ``DataFrame.loc`` to
15+
refer to columns in a declarative way.
16+
17+
Example
18+
-------
19+
20+
.. code-block:: python
21+
22+
import pandas as pd
23+
24+
df = pd.DataFrame({"a": [1, 2, 3]})
25+
df.assign(b=pd.col("a") + 5)
26+
27+
**Supported Operations**
28+
29+
- Arithmetic: ``+``, ``-``, ``*``, ``/``
30+
- Comparison: ``<``, ``>``, ``==``, ``!=``
31+
- Universal functions (ufuncs): can be applied directly
32+
- Series accessors: ``.dt``, ``.str``, ``.cat``
33+
- Series methods: ``.sum()``, ``.mean()``, ``.astype()``, etc.

doc/source/reference/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ to be stable.
5656
testing
5757
missing_value
5858
aliases
59+
api.typing.Expression
60+
5961

6062
.. This is to prevent warnings in the doc build. We don't want to encourage
6163
.. these methods.

0 commit comments

Comments
 (0)