Skip to content

Commit

Permalink
docs: Add narwhals.dtypes.Date docstring example (#1528)
Browse files Browse the repository at this point in the history
* docs: Add docstring examples for Date

* Update narwhals/dtypes.py

Co-authored-by: Francesco Bruzzesi <[email protected]>

---------

Co-authored-by: Francesco Bruzzesi <[email protected]>
ontowhee and FBruzzesi authored Dec 6, 2024
1 parent 6f49ff9 commit b0c1e0e
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion narwhals/dtypes.py
Original file line number Diff line number Diff line change
@@ -698,4 +698,23 @@ def __repr__(self) -> str:


class Date(TemporalType):
"""Data type representing a calendar date."""
"""Data type representing a calendar date.
Examples:
>>> import pandas as pd
>>> import polars as pl
>>> import pyarrow as pa
>>> import narwhals as nw
>>> from datetime import date, timedelta
>>> data = [date(2024, 12, 1) + timedelta(days=d) for d in range(4)]
>>> ser_pd = pd.Series(data, dtype="date32[pyarrow]")
>>> ser_pl = pl.Series(data)
>>> ser_pa = pa.chunked_array([data])
>>> nw.from_native(ser_pd, series_only=True).dtype
Date
>>> nw.from_native(ser_pl, series_only=True).dtype
Date
>>> nw.from_native(ser_pa, series_only=True).dtype
Date
"""

0 comments on commit b0c1e0e

Please sign in to comment.