Skip to content

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 #

tracking_id = UUID(str(tracking_id))

The platform's id for this resource.

metadata property #

metadata: ResourceRead

Return the generated resource projection.

type property #

type: ResourceType

Return the canonical resource type.

content_hash #

content_hash() -> str

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 #

as_df(*, year_min: int | None = None, year_max: int | None = None, **filters: str) -> pd.DataFrame

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 #

as_arrow(*, year_min: int | None = None, year_max: int | None = None, **filters: str) -> pa.Table

Return the resource as a PyArrow table.

as_scmrun #

as_scmrun(*, year_min: int | None = None, year_max: int | None = None, **filters: str) -> ScmRun

Return timeseries data as an scmdata ScmRun.

scmdata rejects rows with duplicate metadata.

fetch #

fetch() -> bytes

Return verified bytes, using memory proportional to the resource size.

Use as_path() to stream large resources without loading them into memory.

as_path #

as_path() -> Path

Stream and verify the resource, then return its cached path.

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 #

tracking_id = UUID(str(tracking_id))

The platform's id for this resource.

content_hash async #

content_hash() -> str

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 #

as_df(*, year_min: int | None = None, year_max: int | None = None, **filters: str) -> pd.DataFrame

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 #

as_arrow(*, year_min: int | None = None, year_max: int | None = None, **filters: str) -> pa.Table

Return the resource as a PyArrow table.

as_scmrun async #

as_scmrun(*, year_min: int | None = None, year_max: int | None = None, **filters: str) -> ScmRun

Return timeseries data as an scmdata ScmRun.

scmdata rejects rows with duplicate metadata.

fetch async #

fetch() -> bytes

Return verified bytes, using memory proportional to the resource size.

Use as_path() to stream large resources without loading them into memory.

as_path async #

as_path() -> Path

Stream and verify the resource, then return its cached path.