stats_can.scwds
Functions that allow the package to return exactly what the api gives.
Note: StatsCan uses cube/table interchangeably. I'm going to keep cube in my function names where it maps to their api but otherwise I will use table. Hence functions with cube in the function name will take tables as an argument I'm not sure which is less confusing, it's annoying they weren't just consistent.
Attributes:
| Name | Type | Description |
|---|---|---|
SC_URL |
str
|
URL for the Statistics Canada REST api |
TODO
Missing api implementations: GetSeriesInfoFromCubePidCoord GetChangedSeriesDataFromCubePidCoord GetChangedSeriesDataFromVector GetDataFromCubePidCoordAndLatestNPeriods GetFullTableDownloadSDMX
get_changed_series_list() -> list[ChangedSeries]
Gets all series that were updated today.
Returns:
| Type | Description |
|---|---|
list[ChangedSeries]
|
list of changed series, one for each vector and when it was released. Returns an empty list if no series have been released yet today. |
Source code in src/stats_can/scwds.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
get_changed_cube_list(date: dt.date | None = None) -> list[ChangedCube]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date
|
date | None
|
Date to check for table changes, defaults to current date |
None
|
Returns:
| Type | Description |
|---|---|
list[ChangedCube]
|
list of changed cubes, one for each table and when it was updated |
Source code in src/stats_can/scwds.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
get_cube_metadata(tables: str | list[str]) -> list[CubeMetadata]
Take a list of tables and return a list of dictionaries with their metadata
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tables
|
str | list[str]
|
IDs of tables to get metadata for |
required |
Returns:
| Type | Description |
|---|---|
list[CubeMetadata]
|
one for each table with its metadata |
Source code in src/stats_can/scwds.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
get_series_info_from_cube_pid_coord()
Not implemented yet
Source code in src/stats_can/scwds.py
169 170 171 172 173 174 | |
get_series_info_from_vector(vectors: str | list[str]) -> list[SeriesInfo]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vectors
|
str | list[str]
|
vector numbers to get info for |
required |
Returns:
| Type | Description |
|---|---|
list[SeriesInfo]
|
List of dicts containing metadata for each v# |
Source code in src/stats_can/scwds.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
get_changed_series_data_from_cube_pid_coord()
Not implemented yet
Source code in src/stats_can/scwds.py
204 205 206 207 208 209 | |
get_changed_series_data_from_vector()
Not implemented yet
Source code in src/stats_can/scwds.py
212 213 214 215 216 217 | |
get_data_from_cube_pid_coord_and_latest_n_periods()
Not implemented yet
Source code in src/stats_can/scwds.py
220 221 222 223 224 225 | |
get_data_from_vectors_and_latest_n_periods(vectors: str | list[str], periods: int) -> list[VectorData]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vectors
|
str | list[str]
|
vector numbers to get info for |
required |
periods
|
int
|
number of periods (starting at latest) to retrieve data for |
required |
Returns:
| Type | Description |
|---|---|
list[VectorData]
|
List of dicts containing data for each vector |
Source code in src/stats_can/scwds.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |
get_bulk_vector_data_by_range(vectors: str | list[str], start_release_date: dt.date, end_release_date: dt.date) -> list[VectorData]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vectors
|
str | list[str]
|
vector numbers to get info for |
required |
start_release_date
|
date
|
start release date for the data |
required |
end_release_date
|
date
|
end release date for the data |
required |
Returns:
| Type | Description |
|---|---|
list[VectorData]
|
List of dicts containing data for each vector |
Source code in src/stats_can/scwds.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | |
get_bulk_vector_data_by_reference_period_range(vectors: str | list[str], start_ref_date: dt.date, end_ref_date: dt.date) -> list[VectorData]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vectors
|
str | list[str]
|
vector numbers to get info for |
required |
start_ref_date
|
date
|
start reference period date for the data |
required |
end_ref_date
|
date
|
end reference period date for the data |
required |
Returns:
| Type | Description |
|---|---|
list[VectorData]
|
List of dicts containing data for each vector |
Source code in src/stats_can/scwds.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | |
get_full_table_download(table: str, csv: bool = True) -> str
Take a table name and return a url to a zipped file of that table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
str
|
table name to download |
required |
csv
|
bool
|
download in CSV format, if not download SDMX |
True
|
Returns:
| Type | Description |
|---|---|
str
|
path to the file download |
Source code in src/stats_can/scwds.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
get_code_sets() -> CodeSet
cached
Gets all code sets which provide additional information to describe information and are grouped into scales, frequencies, symbols etc.
Results are cached after the first call. Call
get_code_sets.cache_clear() to force a refresh.
Returns:
| Type | Description |
|---|---|
CodeSet
|
one dictionary for each group of information |
Source code in src/stats_can/scwds.py
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |