跳至內容
tdx-tw
API 參考

共用型別

Records

class Records(tuple[T, ...]):
    info: RecordsInfo

不可變的資料序列,info 為發布資訊。

to_polars

def to_polars() -> pl.DataFrame

匯出為 Polars 表格,巢狀欄位以點號命名。

to_pandas

def to_pandas() -> pd.DataFrame

匯出為 pandas 表格,使用可為空值的 Arrow 欄位。

to_arrow

def to_arrow() -> pa.Table

匯出為 Arrow 表格。

Timestamp

type Timestamp = datetime

MaybeTimestamp

type MaybeTimestamp = Timestamp | None

ServiceDate

type ServiceDate = date

MaybeDate

type MaybeDate = ServiceDate | None

MaybeBool

type MaybeBool = bool | None

MaybeFloat

type MaybeFloat = float | None

Name

class Name(BaseModel):
    zh_tw: str | None
    en: str | None
    ja: str | None
    ko: str | None

TDX 提供的各語言名稱。

Position

class Position(BaseModel):
    longitude: float
    latitude: float
    geohash: str | None

WGS 84 座標。

at

def at(longitude: float, latitude: float) -> Self

以經度與緯度建立座標。

distance_to

def distance_to(other: Position) -> float

計算與另一座標的測地線距離,單位為公尺。

to_shapely

def to_shapely() -> Point

轉換為 Shapely 點。

to_geohash

def to_geohash(precision: int = 9) -> str

轉換為 geohash。

MaybePosition

type MaybePosition = Position | None

ServiceDays

class ServiceDays(BaseModel):
    tag: str | None
    monday: bool | None
    tuesday: bool | None
    wednesday: bool | None
    thursday: bool | None
    friday: bool | None
    saturday: bool | None
    sunday: bool | None
    national_holidays: bool | None
    typhoon_day: bool | None

RecordsInfo

class RecordsInfo(BaseModel):
    authority_code: str | None
    updated_at: MaybeTimestamp
    update_interval: int | None
    source_updated_at: MaybeTimestamp
    source_update_interval: int | None
    version: int | None
    link_version: str | None
    count: int | None
    service_date: MaybeDate
    effective_date: MaybeDate
    expiry_date: MaybeDate