Alkmaar     +31659380335

Data Engineering and Analytics

Ingest Netherlands GDP Data to Databricks for Free

By Farnam Iranpour

If you’re working with data on Databricks and need access to Netherlands GDP information, you’re in luck! The CBS (Statistics Netherlands) offers free and easy access to this data via its Python library, cbsodata. In this blog post, we’ll walk you through the process of ingesting Netherlands GDP data into your Databricks environment effortlessly.

Step-by-Step Guide

Step 1: Install the cbsodata Library

First, you’ll need to install the cbsodata library. This library allows you to easily retrieve datasets published by CBS. You can install it using pip:

!pip install cbsodata

Step 2: Fetch the Data

With the library installed, you can now fetch the GDP data. The identifier for the dataset we are interested in is 84087ENG. Here’s how you can retrieve the data and load it into a Pandas DataFrame:
data = pd.DataFrame(cbsodata.get_data(‘84087ENG’))

Step 3: Select the Relevant Columns

The dataset contains numerous columns, but for this example, we’ll focus on the GrossDomesticProduct_21 column, which represents the GDP values. We’ll also include the Periods column to keep track of the time periods:

data = data[[‘Periods’, ‘GrossDomesticProduct_21’]]

Step 4: Convert Pandas DataFrame to Spark DataFrame

Databricks is optimized for working with Spark DataFrames, so the next step is to convert our Pandas DataFrame to a Spark DataFrame:

spark_data = spark.createDataFrame(data)

Step 5: Display the Spark DataFrame

Finally, you can display the Spark DataFrame in your Databricks notebook to verify that the data has been loaded correctly:

display(spark_data)

Complete Code Example

Here’s the complete code snippet for easy reference:

Conclusion

By following these simple steps, you can easily ingest Netherlands GDP data into your Databricks environment for free. The cbsodata library provides a straightforward way to access a wealth of statistical data from CBS, making it a valuable tool for data analysts and researchers.

Whether you’re performing economic analysis, building data models, or conducting research, having access to reliable and up-to-date GDP data is crucial. With Databricks and the cbsodata library, you can streamline your data ingestion process and focus on deriving insights from your data.

Happy Data Engineering!