This notebook shows how to use utils function. In particular we show how to pull data of electricity exchange.
We first import utils
function. This lets you access a set of handy functions :
In [1]:
from utils import *
# Enable inline plotting
%matplotlib inline
from ggplot import *
We then pull exchange data for France, between Nov. 2016 and Jan. 2017. To achieve this, we use the function get_exchange
:
In [2]:
df_exchange = get_exchange(['FR'],'2016-11-01','2017-01-10', 1440)
Let's take a first look at the dataframe returned. In the example below, the first row means that France exported on Nov. 1st, 6260 MW to Germany.
In [3]:
df_exchange.head()
Out[3]:
Let's run a quick analysis : on the above period, to which country France has exported the most ? From which country it has imported the most ?
Looking at the table below, it looks like France has imported the most power from Belgium (71 154 MW), and has exported the most power to Spain (100 527 MW).
In [4]:
df_exchange.groupby('country_to').sum().sort_values('net_flow',ascending=False)
Out[4]:
How does this evolve in time ? In the graph below, we show how electricity exchanges have evolved from November to January. We notice for instance that import and export vary with a given country.
For instance, France exported a lot of electricity to Germany during November, but started importing more in December :
In [5]:
df_exchange['timestamp'] = df_exchange['timestamp'].apply(lambda x: arrow.get(x).datetime)
In [6]:
ggplot(aes(x='timestamp',y='net_flow', colour='country_to'),data=df_exchange) +\
geom_line() +\
ggtitle('Evolution of French Electricity Exchange (Nov 2016, Jan 2017)') +\
xlab('Date') +\
scale_x_date(labels = date_format("%b")) +\
facet_wrap('country_to') +\
theme_bw()
Out[6]: