uscensus

class dartfx.uscensus.uscensus.UsCensusAggregatedDataset(*, api: UsCensusApi, c_dataset: list[str], c_vintage: int | None = None, c_geographyLink: str, c_variablesLink: str, c_tagsLink: str, c_examplesLink: str, c_groupsLink: str, c_sorts_url: str, c_documentationLink: str, c_isAggregate: bool | None = False, c_isMicrodata: bool | None = False, c_isTimeseries: bool | None = False, c_isCube: bool | None = False, c_isAvailable: bool | None = False, type: str, title: str, accessLevel: str, bureauCode: list[str], description: str, distribution: list[dict], contactPoint: dict, identifier: str, keyword: list[str], license: str, modified: str, programCode: list[str], references: list[str], spatial: str | None = None, temporal: str | None = None, publisher: dict)[source]

Bases: UsCensusDataset

model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) → None

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self – The BaseModel instance.

  • context – The context.

class dartfx.uscensus.uscensus.UsCensusApi(api_key: str | None = None, session: CachedSession | None = None, *, user_agent: str = 'dartfx-uscensus/0.0.1')[source]

Bases: BaseModel

Helper to call the U.S. Census data API

api_key: str | None
get_dcat_json() → dict[source]

Returns the data catalog as a JSON object.

get_dcat_xml() → Element[source]

Returns the data catalog as an XML object.

get_request(path, description=None, headers=None, **kwargs)[source]

Call the API using the GET method.

model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) → None

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self – The BaseModel instance.

  • context – The context.

post_request(path, description=None, **kwargs)[source]

Call the API using the POST method.

request(method, path, description=None, content_type='application/json', **kwargs)[source]

Call the API.

user_agent: str
exception dartfx.uscensus.uscensus.UsCensusApiError(message, url, status_code=None, response=None)[source]

Bases: Exception

Custom exception for U.S. Census API errors.

class dartfx.uscensus.uscensus.UsCensusCatalog(api: UsCensusApi, load_data: bool = True)[source]

Bases: BaseModel

api: UsCensusApi
property datasets: dict[str, UsCensusDataset]
get_dataset(dataset_id: str) → UsCensusDataset[source]
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) → None

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self – The BaseModel instance.

  • context – The context.

refresh()[source]
search_datasets(is_aggregate: bool | None = None, is_cube: bool | None = None, is_microdata: bool | None = None) → list[UsCensusDataset][source]

Search for datasets.

property stats
class dartfx.uscensus.uscensus.UsCensusDataset(*, api: UsCensusApi, c_dataset: list[str], c_vintage: int | None = None, c_geographyLink: str, c_variablesLink: str, c_tagsLink: str, c_examplesLink: str, c_groupsLink: str, c_sorts_url: str, c_documentationLink: str, c_isAggregate: bool | None = False, c_isMicrodata: bool | None = False, c_isTimeseries: bool | None = False, c_isCube: bool | None = False, c_isAvailable: bool | None = False, type: str, title: str, accessLevel: str, bureauCode: list[str], description: str, distribution: list[dict], contactPoint: dict, identifier: str, keyword: list[str], license: str, modified: str, programCode: list[str], references: list[str], spatial: str | None = None, temporal: str | None = None, publisher: dict)[source]

Bases: BaseModel

class Geography(*, default: list[dict], fips: list[Fips])[source]

Bases: BaseModel

class Fips(*, name: str, geoLevelDisplay: str, referenceDate: str, requires: list[str] | None = None)[source]

Bases: BaseModel

geoLevelDisplay: str
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str
referenceDate: str
requires: list[str] | None
default: list[dict]
fips: list[Fips]
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class Variable(*, name: str, label: str, concept: str | None = None, predicateType: str | None = None, group: str, limit: int, is_weight: bool | None = None, suggested_weight: str | None = None, values: Values | None = None, predicateOnly: bool | None = None)[source]

Bases: BaseModel

class Values(*, item: dict[str, str] | None = None, range: list[Range] | None = None)[source]

Bases: BaseModel

class Range(*, min: str, max: str, description: str)[source]

Bases: BaseModel

description: str
max: str
min: str
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

item: dict[str, str] | None
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

range: list[Range] | None
property codelist
concept: str | None
property croissant_data_type
group: str
is_weight: bool | None
label: str
limit: int
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str
predicateOnly: bool | None
predicateType: str | None
suggested_weight: str | None
values: Values | None
accessLevel: str
property access_url
api: UsCensusApi
bureauCode: list[str]
c_dataset: list[str]
c_isAggregate: bool | None
c_isAvailable: bool | None
c_isCube: bool | None
c_isMicrodata: bool | None
c_isTimeseries: bool | None
c_sorts_url: str
c_vintage: int | None
contactPoint: dict
description: str
distribution: list[dict]
property geography
get_croissant(include_computed=False) → Metadata[source]
get_dcat_us()[source]
get_ddi_codebook(codebook_version='2.5', include_schema=False) → str[source]

Generate DDI-Codebook XML for this dataset.

This generates an XML string so we do not have a dependency on XML packages and developers can use the one they like….

Returns:

The DDI-Codebook XML

Return type:

str

property id
identifier: str
keyword: list[str]
license: str
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) → None

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self – The BaseModel instance.

  • context – The context.

modified: str
property name: str
programCode: list[str]
publisher: dict
references: list[str]
spatial: str | None
property stats
temporal: str | None
title: str
type: str
property variables
class dartfx.uscensus.uscensus.UsCensusMicrodataDataset(*, api: UsCensusApi, c_dataset: list[str], c_vintage: int | None = None, c_geographyLink: str, c_variablesLink: str, c_tagsLink: str, c_examplesLink: str, c_groupsLink: str, c_sorts_url: str, c_documentationLink: str, c_isAggregate: bool | None = False, c_isMicrodata: bool | None = False, c_isTimeseries: bool | None = False, c_isCube: bool | None = False, c_isAvailable: bool | None = False, type: str, title: str, accessLevel: str, bureauCode: list[str], description: str, distribution: list[dict], contactPoint: dict, identifier: str, keyword: list[str], license: str, modified: str, programCode: list[str], references: list[str], spatial: str | None = None, temporal: str | None = None, publisher: dict)[source]

Bases: UsCensusDataset

model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) → None

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self – The BaseModel instance.

  • context – The context.

class dartfx.uscensus.uscensus.UsCensusTimeSeriesDataset(*, api: UsCensusApi, c_dataset: list[str], c_vintage: int | None = None, c_geographyLink: str, c_variablesLink: str, c_tagsLink: str, c_examplesLink: str, c_groupsLink: str, c_sorts_url: str, c_documentationLink: str, c_isAggregate: bool | None = False, c_isMicrodata: bool | None = False, c_isTimeseries: bool | None = False, c_isCube: bool | None = False, c_isAvailable: bool | None = False, type: str, title: str, accessLevel: str, bureauCode: list[str], description: str, distribution: list[dict], contactPoint: dict, identifier: str, keyword: list[str], license: str, modified: str, programCode: list[str], references: list[str], spatial: str | None = None, temporal: str | None = None, publisher: dict)[source]

Bases: UsCensusDataset

model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) → None

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self – The BaseModel instance.

  • context – The context.