Pagination¶
pagination
¶
Lazy collections over Django REST Framework style list endpoints.
Classes:
| Name | Description |
|---|---|
Page |
One page of results from a list endpoint. |
PaginatedList |
An iterable view over a paginated endpoint that fetches pages on demand. |
Functions:
| Name | Description |
|---|---|
to_dataframe |
Convert models (or plain dicts) into a |
PANDAS_INSTALL_HINT
module-attribute
¶
PANDAS_INSTALL_HINT = "pandas is required for .to_df(); install it with `uv add 'datamermaid[pandas]'` or `pip install 'datamermaid[pandas]'`"
Page
dataclass
¶
PaginatedList
¶
PaginatedList(
fetch_page: Callable[[str | None], Page[T]],
)
Bases: Generic[T]
An iterable view over a paginated endpoint that fetches pages on demand.
Nothing is requested until the list is iterated, indexed, or measured. Fetched items are cached, so re-iterating or indexing backwards never issues another request.
Methods:
| Name | Description |
|---|---|
to_df |
Materialise every page and return the results as a DataFrame. |
Attributes:
| Name | Type | Description |
|---|---|---|
count |
int | None
|
Total number of matching records, as reported by the API. |
fetched |
list[T]
|
The items fetched so far, without triggering a request. |
to_df
¶
Materialise every page and return the results as a DataFrame.
Requires the optional pandas extra.
to_dataframe
¶
Convert models (or plain dicts) into a pandas.DataFrame.