[PYTHON] Standard area code current value

It turned out that it would be okay if the URL list of the local government was prepared based on the "national local government code". I want "National Local Public Organization Code" data.

The "standard area code", which is a superset of the "national local government code", is not set for each local government, but for all the places where you want to take statistical values, so the "standard area code" does not support the homepage. There are many areas. This is too much.

The RDF schema of the regional standard code itself is well-developed, and I wondered if it would be possible to maintain the "national local government code" with reference to this. At present, it is distributed by excel, so for example, you can read it with pandas.read_excel and use it while removing dust.

However, I thought that the system of CurrentStandardAreaCode of" standard area code "was a little" hmm ". Personally, I want to design the data as statically as possible. The difficulty is that if you write dynamic data like "current" in a file, it will be a lie in the future.

So, for example, without using CurrentStandardAreaCode, I tried to calculate the equivalent. You can see the changes before and after with CodeChangeEvent, so let's put out the surviving code group.

PREFIX org: <http://www.w3.org/ns/org#>
PREFIX sac: <http://data.e-stat.go.jp/lod/sac/>
PREFIX sacs: <http://data.e-stat.go.jp/lod/terms/sacs#>
PREFIX sace: <http://data.e-stat.go.jp/lod/sace/>

SELECT DISTINCT ?s WHERE {
  ?s a sacs:StandardAreaCode .
  ?e a sacs:CodeChangeEvent ;
     org:resultingOrganization ?s .

  FILTER NOT EXISTS {
     ?e2 org:originalOrganization ?s .
  }
}

However, this does not match the number of CurrentStandardAreaCode. Execution result. Looking at the cause, for example, "Sagamihara City has moved to an ordinance-designated city" is recorded as a revision in the "National Local Public Organization Code".

Name of prefectures Pre-revision code City name Furigana Revised classification Amendment date Revised code City name Furigana Reasons, etc.
Kanagawa Prefecture 142093 Sagamihara City Sagamihara City Missing number H22.4.1 Delete Delete Delete Moved to a government-designated city
Newly established 141500 Sagamihara City Sagamihara City
141518 Midori Ward Green
141526 Chuo-ku Chuo-ku
141534 Minami Ward Minamiku

The record in the "standard area code" is as follows.

sace:C5174
      rdf:type sacs:CodeChangeEvent ;
      sacs:reasonForChange sacr:shiftToDesignatedCity ;
      dcterms:date "2010-04-01"^^xsd:date ;
      dcterms:description "Sagamihara-shi(14209) shifts to a city designated by the Cabinet Order, and it becomes Sagamihara-shi(14150)."@en , "Sagamihara City(14209)のSagamihara City(14150)Transition to an ordinance-designated city"@ja ;
      dcterms:identifier "5174" ;
      org:originalOrganization
              sac:C14209-20071201 ;
      org:resultingOrganization
              sac:C14209-20100401 , sac:C14150-20100401 .

sace:C5175
      rdf:type sacs:CodeChangeEvent ;
      sacs:reasonForChange sacr:establishmentOfWards ;
      dcterms:date "2010-04-01"^^xsd:date ;
      dcterms:description "Midori-ku(14151), Chuo-ku(14152) and Minami-ku(14153) are newly established in Sagamihara-shi."@en , "Midori Ward(14151),Chuo-ku(14152), Minami Ward(14153)Newly established"@ja ;
      dcterms:identifier "5175" ;
      org:resultingOrganization
              sac:C14151-20100401 , sac:C14152-20100401 , sac:C14153-20100401 .

If you read the "National Local Public Organization Code" normally, it seems that sac: C14209-20100401 is not necessary. Why is it added? Why is it such a system? You can see it by querying. Execution result.

PREFIX sac: <http://data.e-stat.go.jp/lod/sac/>
select  * 
where {
      ?s ?p sac:C14209-20100401 .
} 
limit 10

Does that mean that when there is data being aggregated with the code 14209 at the beginning, it cannot be suddenly changed to 14150? Although the "standard area code" was extended locally such as counties, agencies, and bureaus, it turned out that the code was actually expanded in the time direction as well.

I see.

Recommended Posts

Standard area code current value
Write standard input in code
High value code per line