E-mobility in Germany: Analysis of electric vehicle charging stations

Munich is leading e-mobility in Germany 💚

Amanda Iglesias Moreno
Towards Data Science

--

Photo by Jannes Glas on Unsplash

Electric mobility plays an important role to guarantee a sustainable future around the world. The popularity of electric vehicles is continuously increasing and they represent an appealing alternative to the internal combustion engine. However, to ensure the success of electric mobility, it is required the availability of good infrastructure for charging electric vehicles.

In this article, we analyze the charging stations located across Germany. The data can be found on the following webpage and contains the public charging points available in Germany (and reported to the Bundesnetzagentur!). It is possible that in other sources you find charging locations not available in this data set.

The article is divided into 4 parts:

  • Data set of EV charging stations in Germany
  • Data frame translation
  • Exploratory data analysis and data cleaning
  • Answering questions and drawing conclusions

If you are only interested in the results obtained, go directly to the last part of the article! ▶️

Data set of EV charging stations in Germany

After downloading the CSV file from bundesnetzagentur.de, we can load it into a Pandas data frame using the pandas.read_csv function and visualize the first 5 rows using the pandas.DataFrame.head method.

As shown above, we skip 5 rows at the start of the file (skiprows=5) since they do not contain useful information (just explanatory notes about the data being displayed).

Data frame translation

The Bundesnetzagentur provides data sets in German. Therefore, before starting with the exploratory data analysis, we have to translate the data set into English. First, we translate column names using the pandas.DataFrame.rename function.

Then, we translate the entries of the column type_of_charger using the pandas.Series.replace method as shown below.

We are not going to translate the entries of the rest of the columns. But, in case you want to translate them, you can use the googletrans library, since those columns contain multiple unique elements. In this case, hard coding the translation would be highly time-consuming.

The data frame is translated! Now, we are ready to start the exploratory data analysis.

Exploratory data analysis and data cleaning

Exploratory data analysis consists of analyzing the main characteristics of a data set usually by means of visualization methods and summary statistics. The objective is to understand the data, discover patterns and anomalies, and check assumptions before we perform further evaluations.

At the beginning of EDA, we want to know as much information as possible about the data, this is when the pandas.DataFrame.info method comes in handy. This method prints a concise summary of the data frame, including the column names and their data types, the number of non-null values, the amount of memory used by the data frame.

As shown above, the data frame contains 13551 observations and 22 variables. The columns type_of_plug_2, p2[kw], type_of_plug_3, p3[kw], type_of_plug_4, and p4[kw] contain null values, meaning a second, third, and forth charging point is not available at the charging station (remember that a charging station can have multiple charging points). We replace null values by the string ‘0’ using the pandas.Series.fillna function, indicating that a charging point is not available.

Public keys are sequences of numbers that allow the user to remotely check measured values. As they do not provide useful information for our analysis, we are going to drop these columns.

As we can observe below, now, the data frame does not contain now null values.

After removing null values, we modify incorrect data types. We can examine the data types of the columns using pandas.DataFrame.info method (as we did previously) or with pandas.DataFrame.dtypes attribute. This attribute returns a Series with the data type of each column.

As shown above, the following columns : (1) longitud_[dg], (2) latitude_[dg], (3) power_connection_[kw], (4) p1_[kw], (5) p2_[kw], (6) p3_[kw], and (7) p4_[kw] are of data type object instead of float. We can use the pandas.Series.astype method to convert the data type of these columns to float, replacing previously commas with dots.

Additionally, we have to convert the column commissioning_date to datetime. To achieve this, we can use the pandas.to_datetime method, specifying the format to match the data.

Now, we can run the pandas.DataFrame.info method again to check that inappropriate data types and null values were correctly modified.

As shown above, the data set does not contain null values and the data types are the expected ones.

Tidy datasets have the following structure:

  • Each variable is in one column.
  • Each observation is in a different row.
  • Each type of observational unit is in a different table.

As you can observe, the column postcode_city contains two variables: (1) postcode and (2) city; therefore, we need to split this column into two different columns. To do so, we can use the string method split (pandas.Series.str.split), setting the parameters n=1 and expand=True.

Leading and trailing spaces are a common problem when working with object columns in Pandas. We must make sure that the entries of the columns do not contain whitespaces at the beginning and end, since they may lead to wrong conclusions when analyzing the data.

The following code shows that several city names contain leading or trailing spaces.

We need to delete them to avoid problems when grouping the data, since for instance ‘ Regensburg’ and ‘Regensburg’ will be considered different cities if we do not eliminate the leading space.

As shown below, we loop through the columns that are object data type and remove all whitespaces at the beginning and end of the entries with the pandas.Series.str.strip method.

Finally, we have to address the last and more challenging cleaning problem. In some cases, two different names for the same city were introduced in the data set (e.g. Frankfurt and Frankfurt am Main). At other times, the district name was also recorded along with the name of the city (e.g Stuttgart-Mühlhausen).

We can identify wrong city names using the pandas.Series.str.contains method as shown below.

We look for the most important German cities and create a dictionary, mapping wrong names to correct denominations. Then, we use this dictionary with the pandas.Series.replace function to modify wrong city names.

The dataset contains some more wrong denominations but at least we have corrected the city names that will appear later in the visualizations.

Lastly, I want to point out that the data frame contains multiple duplicated rows as shown below.

These duplicated observations should not be removed since they represent several charging stations located at the same point.

Data cleaning is finished 💚. Now, we are ready to answer questions and draw conclusions using the data.

Answering questions and drawing conclusions

Exploratory data analysis and data cleaning are the steps that allow us to get a feeling about the data and to get it ready to easily draw conclusions. Now! We are ready to answer the following questions using the dataset.

Number of charging stations by federal state

The following plot shows that Bavaria (3090) is the state with the highest number of EV charging stations followed by North Rhine-Westphalia (2392) and Baden-Württemberg (1942). On the contrary, the state of Saarland has only 91 EV charging stations. This makes sense because Saarland is a sparsely populated state with no large cities.

Which cities have the most EV charging station in Germany?

As shown below, Munich (607) is the city with the most EV charging stations in Germany followed by Hamburg (535) and Berlin (519). Cologne takes fourth place at the ranking; however, it has far fewer charging stations (134).

In fact, more than 12% of the charging stations in Germany are located in Munich, Hamburg, or Berlin as shown below.

Which cities have the most EV charging points in Germany?

A charging station can have multiple charging points. The following pie chart depicts the percentage of charging stations with 1, 2, 3, and 4 charging points.

As shown above, over 80% of charging stations in Germany have 2 charging points. On the contrary, only 1.3% of stations have 3 load points.

The following plot shows that Munich, Hamburg, and Berlin are the cities with the most EV charging point as well.

When were the charging stations put into operation?

The following plot shows how many charging stations were put into operation each year (commissioning date). As you can observe, there is an increasing trend in the number of new charging stations installed over the years.

As shown above, the percentage of change between the current and the prior year is always positive with the exception of 2012 and 2020. It is important to point out that the data set contains information until 5 May 2020.

However, with the coronavirus crisis, it is expected a fewer number of new charging stations in 2020 than in 2019.

Power of the charging points in Germany

The charging time of an EV depends on the power of the charging point and the battery capacity of the vehicle.

Charging Time [h] = Battery Capacity [kwh] / Charging Power [kw]

For this reason, the power output of the charging point is an important factor to consider, as it determines the charging speed.

The following table shows the most common power outputs of charging points in Germany.

There are 20741 charging points of 22kW, being this the most common power output in Germany followed by 11kW. On the other hand, ultra-rapid charging points of 150kW and 350kW are less common; however, you can find more than 450 of them across Germany.

As shown below, we can find 62 different power outputs for charging electric vehicles in Germany. These outputs are listed below in ascending order, being 22.0, 11.0, 50.0, 43.0, 3.7, 350.0, 150.0, 42.0, 20.0, 53.0 kW the most common ones (see table above).

The following pie plot shows the percentage of charging points according to the power output.

As you can observe, 78.28% of the charging points in Germany have a charging power of 22kW. Ultra-rapid chargers (350kW) represent only 1.24% of the total charging points, being the maximum charging power installed in Germany.

Where are ultra-rapid chargers (>300 kW) located? When were they installed?

Ultra-rapid charging points are those that have a charging power larger than or equal to 300 kW. As we have seen above, there are only three different power outputs which meet this requirement: 300, 320, and 350 kW.

The following block of code shows that 6 charging points of 300 kW, 10 of 320 kW, and 328 of 350 kW are in operation in Germany, which makes a total of 344 ultra-rapid charging points.

As we have mentioned before, a charging station can have multiple charging points. In the case of Germany, we can find charging stations with up to 4 charging points.

There are in total 341 charging stations with ultra-rapid charging points as shown below.

The charging points of 350 kW and 320 kW are located in charging stations with only one charging point. On the contrary, there are 3 charging stations with 2 charging points of 300 kW as you can see below.

These stations are located mainly in Bavaria where you can find more than 80 stations with ultra-rapid chargers.

The following plot shows that stations with ultra-rapid chargers (>300 kW) were put into operation for the first time in 2018. Additionally, we observe that most stations with ultra-rapid chargers were installed in 2019.

The first EV charging station in Germany was installed in July 2008, and it was not until 10 years later, in March 2018, that the first station with an ultra-rapid charger (>300 kW) was installed.

The total number of EV charging stations in operation in the largest German cities

Next, we are going to explain step by step how to obtain the total number of charging stations by year in the largest German cities: (1) Berlin, (2) Hamburg, (3) München, (4) Köln, (5) Frankfurt am Main, (6) Stuttgart, (7) Düsseldorf, (8) Dortmund, (9)Essen, and (10) Leipzig.

First, we use the pandas.DataFrame.groupby function. This function involves some combination of splitting the object, applying a function, and combining the results.

We obtain a multi-index data frame, since grouping by two columns will give you two indices. We select one column (e.g. operator) as all the columns provide the same information (count). Then, we use the pandas.DataFrame.unstack function. This function pivots the innermost index level to a new column level. The result is a data frame (date_cities) where the columns represent the cities and the rows the commissioning date, being the values the number of charging stations put in operation in a particular year and city. As we want to analyze only the largest cities in Germany, we select the corresponding columns in the data frame (date_cities_10).

The data frame above contains the number of charging stations put in operation in a particular year and city. As we are interested in the total number of charging stations by city over the years, we have to calculate the cumulative sum, replacing previously null values by 0. Then, we use the plot function to create a multi-line plot where each line represents a city.

As shown above, the total number of charging stations in Köln, Frankfurt am Main, Stuttgart, Düsseldorf, Dortmund, Essen, and Leipzig grows slowly over the years. On the contrary, the rate of growth in Berlin, Hamburg, and Munich has become much larger since 2016.

Distribution of charging station in Munich

The best way to analyze geospatial data is by using maps. Folium is a data visualization library that allows generating Leaflet web maps directly from your Python code. First, we need to install it, since the Folium package is not part of the Python Standard Library. To do so, we run the following command in the Windows Terminal:

pip install folium

After installing and importing Folium, we can generate a map object with the folium.map() function. The location argument allows us to center the map in a specific location (in our case Munich). We can also provide an initial zoom level to zoom the map into the center.

The map generated is interactive, meaning you can easily zoom in and out.

The data frame contains the latitude and longitude where the charging stations are located. We can plot circle markers at these locations using the CircleMarker() function.

The following map shows where charging stations are located across Munich. As you can observe, the charging stations are quite evenly distributed across the city. However, there are more stations in the center of the city than on the outskirts.

In the image above, you can observe that some markers are more opaque than others, meaning multiple stations are located at the same point (overlapping circle markers).

As we previously mentioned, a charging station can have multiple charging points. The number of charging points of stations in Munich follows the following distribution:

  • 1 Charging point: 3.95%
  • 2 Charging points: 95.06%
  • 3 Charging points: 0.16%
  • 4 Charging points: 0.82%

We can customize the radius and the color of the marker according to the number of charging points as follows.

As you can observe, most of the stations have two charging points (purple dots). The stations with 4 charging points (blue dots) are located on the outskirts of Munich.

The data frame contains one column indicating the type of charging station: (1) normal, or (2) fast. A charging station is considered fast if it has at least 1 charging point with a power output larger than 22kw as shown below.

In the following map, normal-charging stations are represented with blue markers. On the contrary, fast-charging stations are depicted in red.

As shown above, most stations are normal, meaning all charging points have a power output lower than 22kW. There are only 10 fast-charging stations in Munich. Arabella Park (and surroundings) is the location with more fast-charging stations (5 in total).

Now it is your turn! You can generate maps of other cities and visualize how the charging stations are distributed across them 🌐

We finish our analysis here. However, there are still many questions you can answer using this data. For example: How many companies are in charge of charging stations? How many different plugs are available in Germany? Which is the most common plug in Germany? … and many more! 🙋

Key Takeaways

  • Bavaria is the federal state with more EV charging stations (roughly 3000).
  • Munich, Hamburg, and Berlin are the cities with the highest number of EV charging stations in Germany.
  • A charging station can have multiple charging points (1, 2, 3, or 4). Over 80% of the EV charging stations in Germany have 2 charging points.
  • The number of new charging stations in operation is increasing over the years.
  • 78.3% of the charging points in Germany have a charging power of 22kW. Ultra-rapid chargers (350kW) represent only 1.24% of the total charging points.
  • The first ultra-rapid charger (>300kW) was put into operation in 2018.
  • The total number of charging stations in Köln, Frankfurt am Main, Stuttgart, Düsseldorf, Dortmund, Essen, and Leipzig grows slowly over the years. On the contrary, the rate of growth in Berlin, Hamburg, and Munich has become much larger since 2016.

Thanks for reading 💜

Amanda

--

--