Package: cso-ireland-data
CSO Ireland Data==============================Easily download data from the CSO PxStat API as Pandas datasets.Usesrequests-cachefor super fast access to cached requests and easy persistence with multiple storage backends.InstallationTo install, just use pip:pipinstallcso-ireland-dataUsageGetting startedFirst, set up aCSODataSession.By default, this is really simple.fromcso_ireland_dataimportCSODataSessioncso=CSODataSession()If you want to add caching, no problem! All the functionality oftherequests-cachepackageis available throughcached_session_params.fromdatetimeimporttimedeltafromcso_ireland_dataimportCSODataSessioncso=CSODataSession(cached_session_params={"use_cache_dir":True,# Save files in the default user cache dir"cache_control":True,# Use Cache-Control response headers for expiration, if available"expire_after":timedelta(days=1),# Otherwise expire responses after one day})Stuck behind a corporate firewall that causes SSL certificate issues? Also no problem! All the functionality oftherequestsget()methodis available throughrequest_params.fromcso_ireland+dataimportCSODataSession# Tell requests.get() it's ok not to verify SSL certificates when getting data.# !!! Only do this if you're absolutely sure it's what you need !!!cso=CSODataSession(request_params={"verify":False})Getting the data catalogueTo get a catalogue (Table of Contents) of all the datasets that are available through the API, useget_toc().NB Requests for the ToC sometimes time out on the CSO API. IF this happens, try again!cso.get_toc()table_idtable_namelast_updatedcopyrightexceptionalfrequencyearliestlatestvariablesA01011996 Population and Percentage Change  1991 and 19962020-05-01 11:00:00+00:00Central Statistics Office, IrelandFalseCensusYear19961996['Province County or City']A0102Population at Each Census Since 18412020-05-01 11:00:00+00:00Central Statistics Office, IrelandFalseCensusYear18411996['Province or County', 'Sex']A0103Population2020-05-01 11:00:00+00:00Central Statistics Office, IrelandFalseCensusYear19961996['Province County or City', 'Sex', 'Aggregate Town or Rural Area']A0104Population2020-06-03 11:00:00+00:00Central Statistics Office, IrelandFalseCensusYear19961996['Sex', 'Regional Authority']A01051996 Population and Percentage Change 1996 and 20022021-07-19 11:00:00+00:00Central Statistics Office, IrelandFalseCensusYear19961996['Towns by Electoral Division']Getting a table using its ID codeTo get the whole contents of a particular table hosted on the Statbank API, useget_table().You just need to know the ID code of the table, which you can look up usingget_toc().wpm29=cso.get_table("WPM29")wpm29.head()Wholesale Price Index (Excl VAT) for Energy Products('Autodiesel', '2015M01')96.7('Autodiesel', '2015M02')102('Autodiesel', '2015M03')103('Autodiesel', '2015M04')102.9('Autodiesel', '2015M05')104.6Getting some common tables quicklyTheCSODataSessionclass includes some useful methods to get data from commonly accessed tables quickly.Monthly Consumer Price Index (CPI)By default, themonthly_cpi()method returns a single column corresponding to the 'All items' headline CPI in the source table.Also by default, this index is re-normalized to the most recent month - you can toggle this by settingnormalize_to_most_recenttoFalse.simple_cpi=cso.monthly_cpi()simple_cpi.tail()MonthAll items2022-04-01 00:00:000.97252022-05-01 00:00:000.9812022-06-01 00:00:000.99372022-07-01 00:00:000.99862022-08-01 00:00:001It's also possible to pass a list of commodity groups:commmodity_group_cpi=cso.monthly_cpi(commodity_groups=["All items","Alcoholic beverages and tobacco","Health","Recreation and culture",])commodity_group_cpi.tail()MonthAll itemsAlcoholic beverages and tobaccoHealthRecreation and culture2022-04-01 00:00:000.97250.97380.98280.99452022-05-01 00:00:000.9810.99370.98510.99542022-06-01 00:00:000.99370.99580.98740.99732022-07-01 00:00:000.99860.99690.98740.99912022-08-01 00:00:001111Live RegisterUse thelive_register()method to get Live Register numbers (optionally broken down by Age Group and Sex) by month. This is a long data series, starting in April 1967 and still continuing every month, so it may be convenient to specify astartand/orenddate for the data returned.The Live Register data series is based on a monthly point-in-time count of people who have active Jobseeker claims with the Department of Social Protection (DSP), and these counts are extracted from DSP's administrative computer systems on a particular day every month.Because of this,live_register()returns three possibly useful dates for each month:'Month' is the index of the data frame. It's just the last day of each calendar month.'reference_date' is the date of the point-in-time count of people with active Jobseeker claims. It's the last Friday of each month before May 2015, and the last Thursday of the month from then on.'extract_date' is the date on which the source administrative data was actually extracted - it's always the Sunday after the reporting_date.live_register=cso.live_register(start=datetime(2010,1,1))MonthAge GroupSexPersons on the Live RegisterPersons on the Live Register (Seasonally Adjusted)reference_dateextract_date5162010-04-30 00:00:00All agesBoth sexes4326574408002010-04-30 00:00:002010-05-02 00:00:005172010-08-31 00:00:00All agesBoth sexes4669234440002010-08-27 00:00:002010-08-29 00:00:005182010-12-31 00:00:00All agesBoth sexes4370794460002010-12-31 00:00:002011-01-02 00:00:005192010-02-28 00:00:00All agesBoth sexes4369564390002010-02-26 00:00:002010-02-28 00:00:005202010-01-31 00:00:00All agesBoth sexes4369364394002010-01-29 00:00:002010-01-31 00:00:00Life TablesThelife_table()method by default returns a complete life table for the most recent source data vintage.life_table=cso.life_table()life_table.head()IxdxpxqxLxTxe0x('Male', 101)8516160.7244940.27550654315441.82('Male', 102)6164400.7142580.28574239610021.63('Male', 103)4403070.697990.302012876051.38('Male', 104)3072210.719110.280891973191.04('Male', 105)2211980.8961010.1038991221220.55