Resources#
bookshelf.Resource #
Resource(client: BookshelfClient, cache: ContentCache, tracking_id: str | UUID, *, metadata: models.ResourceRead | None = None, resource_type: models.ResourceType | None = None)
Bases: _ResourceHandle
Lean immutable resource handle for machine and provenance reads.
tracking_id instance-attribute #
The platform's id for this resource.
content_hash #
Return the declared sha256: digest, from memory or disk before the platform.
query #
query(*, select: str | None = None, order: str | None = None, year_min: int | None = None, year_max: int | None = None, drop_constant: bool = False, top_n: int | None = None, limit: int | None = None, offset: int | None = None, **filters: str) -> pd.DataFrame
Return pandas data filtered on the server, using wide indexed form for timeseries.
as_df #
Return the whole resource as pandas, using wide indexed form for timeseries.
The year window and column=value filters apply locally, after the download.
as_long_df #
as_long_df(*, year_min: int | None = None, year_max: int | None = None, legacy_columns: bool = False, **filters: str) -> pd.DataFrame
Return tidy pandas timeseries data.
legacy_columns reproduces the 0.4 long format instead: a values column, a year column of YYYY-01-01 00:00:00 strings, and rows sorted by the dimensions and then the year.
as_polars #
as_polars(*, year_min: int | None = None, year_max: int | None = None, **filters: str) -> pl.DataFrame
Return the resource as a Polars DataFrame.
as_arrow #
Return the resource as a PyArrow table.
as_scmrun #
Return timeseries data as an scmdata ScmRun.
scmdata rejects rows with duplicate metadata.
fetch #
Return verified bytes, using memory proportional to the resource size.
Use as_path() to stream large resources without loading them into memory.
bookshelf.AsyncResource #
AsyncResource(client: BookshelfClient, cache: ContentCache, tracking_id: str | UUID, *, metadata: models.ResourceRead | None = None, resource_type: models.ResourceType | None = None)
Bases: _ResourceHandle
Asynchronous lean immutable resource handle.
tracking_id instance-attribute #
The platform's id for this resource.
content_hash async #
Return the declared sha256: digest, from memory or disk before the platform.
query async #
query(*, select: str | None = None, order: str | None = None, year_min: int | None = None, year_max: int | None = None, drop_constant: bool = False, top_n: int | None = None, limit: int | None = None, offset: int | None = None, **filters: str) -> pd.DataFrame
Return pandas data filtered on the server, using wide indexed form for timeseries.
as_df async #
Return the whole resource as pandas, using wide indexed form for timeseries.
The year window and column=value filters apply locally, after the download.
as_long_df async #
as_long_df(*, year_min: int | None = None, year_max: int | None = None, legacy_columns: bool = False, **filters: str) -> pd.DataFrame
Return tidy pandas timeseries data.
legacy_columns reproduces the 0.4 long format instead: a values column, a year column of YYYY-01-01 00:00:00 strings, and rows sorted by the dimensions and then the year.
as_polars async #
as_polars(*, year_min: int | None = None, year_max: int | None = None, **filters: str) -> pl.DataFrame
Return the resource as a Polars DataFrame.
as_arrow async #
Return the resource as a PyArrow table.
as_scmrun async #
Return timeseries data as an scmdata ScmRun.
scmdata rejects rows with duplicate metadata.
fetch async #
Return verified bytes, using memory proportional to the resource size.
Use as_path() to stream large resources without loading them into memory.