The “Core Data” project provides essential data for the data wranglers and data science community. Its online home is on the DataHub:
This post introduces you to the Core Data, presents a couple of examples and shows you how you can access and use core data easily from your own tools and systems including R, Python, Pandas and more.
- Why Core Data
- Use Core Data from your favorite language or tool
Why Core Data
If you build data driven applications or data driven insight you regularly find yourself wanting common “core” data, things like lists of countries, populations, geographic boundaries and more.
However, finding good quality data has always been challenging. Professionals can spend lots of time finding and preparing data before they get to do any real work analysing or presenting it.
To address this, a few years ago we started the “core data” project as part of the Frictionless Data initiative. Its purpose was to curate important, commonly used datasets including reference data like country codes, indicators like population and GDP, and geodata like country boundaries. It provides them in a high-quality, easy-to-use, and standard form.
Recently the Core Data project has got even better with a new home on the newly upgraded DataHub and has expanded thanks to new partners like Datopian and John Snow Labs (more on this in a future post!).
There are dozens of core datasets already available and many more being worked on, including a list of countries and their 2 digit codes, and a more extensive version.
List of Countries
Ever needed to build a drop-down list of countries in a web application? Or ever needed to add country name labels for a graph and only had country codes?
Then these datasets are for you!
First up is the very simple “country-list” dataset:
You can see a preview table for the dataset on the showcase page:
You can download it in either CSV or JSON formats:
- CSV: https://datahub.io/core/country-list/r/data.csv
- JSON: https://datahub.io/core/country-list/r/data.json
Maybe the simple list of countries is not enough for you. Perhaps you need phone codes for each country, or want to know their currencies?
We’ve got you covered with the more extensive country codes dataset:
All the countries from Country List including number of associated codes - ISO 3166 codes, ITU dialing codes, ISO 4217 currency codes, and many others. This dataset includes 26 different codes and associated information.
You can also preview the data and download in different formats just like it is described for Country List dataset above:
- CSV: https://datahub.io/core/country-codes/r/country-codes.csv
- JSON: https://datahub.io/core/country-codes/r/country-codes.json
This is another useful dataset for people: you regularly need population in order to do normalisations and calculate per capita figures as part of a statistical analysis.
This dataset includes population figures for countries, regions (e.g. Asia) and the world. Data comes originally from World Bank and has been converted into standard tabular data package with CSV data and a table schema:
Preview the data on the showcase page:
Get the data in CSV or JSON formats just like for any other Core Datasets:
- CSV: https://datahub.io/core/population/r/population.csv
- JSON: https://datahub.io/core/population/r/population.json
Use Core Data from your favorite language or tool
We have made Core Data easy-to-use from various programming languages and tools. We will walk through using our Country List example. But you can apply these instructions to any other Core Data in the DataHub.
CSV and JSON
If you just need to get data, you have a direct link usable from any tool or app e.g. for the country list:
- CSV - https://datahub.io/core/country-list/r/data.csv
- JSON - https://datahub.io/core/country-list/r/data.json
Following commands help you to get the data using “cURL” tool. Use
-L flag so “cURL” follows redirects:
If you are using R here’s how to get the data you want quickly loaded:
Here we take a look at how to get Country List in Python programming language:
For Python, first install the
datapackage library (all the datasets on DataHub are Data Packages):
Again, we’ll use the
In order to work with Data Packages in Pandas you need to install the Frictionless Data data package library and the pandas extension:
To get the data run following code:
This post has shown how you can import datasets in a high quality, standard form quickly and easily.
There are many more datasets to explore than the three we showed you here. You can find a full list here:
Finally, we would love collaborators to help us curate even more core datasets. If you’re interested you can find out more about the Core Data Curator program here: