<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Exploration of traffic data from lauttasaaren silta
Step1:  First download the dataset and place it in the data/ folder
Step2:  The columns are
Step3:  Since the time series is at uneven intervals some reductions have to be made.
Step4:  Lets define light as
<ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
Explanation: Exploration of traffic data from lauttasaaren silta
End of explanation
data = pd.read_csv('data/hki_liikennemaarat.csv', encoding='latin-1',delimiter=';')
data.head()
Explanation: First download the dataset and place it in the data/ folder:
https://www.avoindata.fi/data/fi/dataset/liikennemaarat-helsingissa
The data is obtained from an automatic meassurement point at: https://www.google.fi/maps/place/60%C2%B009'44.6%22N+24%C2%B053'58.6%22E/@60.1623877,24.8974263,17z/data=!3m1!4b1!4m5!3m4!1s0x0:0x0!8m2!3d60.162385!4d24.899615?hl=en
Legend(in Finnish): ha=henkilöautot pa=pakettiautot ka=kuorma-autot ra=rekka-autot la=linja-autot mp=moottoripyörät rv=raitiovaunut
Laskenta on tehty tunneittain, paitsi ruuhka-aikoina (klo 6.00-9.00 ja 15.00-18.00) jaksotus on 15 minuuttia. Kellonajat ovat alkavia kellonaikoja. Laskentapisteiden poikkileikkaukset lasketaan suunnittain (suunta 1 on keskustaan, linjalla D D1-D13 länteen)
End of explanation
laru = data[data.nimi == 'LAUTTASAAREN SILTA']
laru = laru.loc[:,['suunta','aika','vuosi','autot','ha','pa','ka','ra','la','mp']]
Explanation: The columns are: ha=henkilöautot pa=pakettiautot ka=kuorma-autot ra=rekka-autot la=linja-autot mp=moottoripyörät rv=raitiovaunut
Remove data about trams and other measurement points.
End of explanation
laru['tunti'] = (laru['aika'] / 100).apply(np.floor)
laru
Explanation: Since the time series is at uneven intervals some reductions have to be made.
End of explanation
laru['light traffic'] = laru['ha'] + laru['pa'] + laru['mp']
laru['heavy traffic'] = laru['ka'] + laru['ra'] + laru['la']
laru['buses'] = laru['la']
laru.head()
laru = laru.drop(['autot','ha','pa','ka','ra','la','mp'],axis=1)
laru.head()
yrl = laru.groupby(['vuosi','suunta','tunti']).sum()
yrl.reset_index(inplace=True)
yrl
y_2016_tohel = yrl[(yrl.vuosi == 2016) & (yrl.suunta == 1.0) ]
y_2016_tolaru = yrl[(yrl.vuosi == 2016) & (yrl.suunta == 2.0) ]
y_2016_tohel = y_2016_tohel.drop(['aika','suunta','vuosi'],axis = 1)
y_2016_tolaru = y_2016_tolaru.drop(['aika','suunta','vuosi'],axis = 1)
y_2016_tohel.head()
y_2016_tolaru.head()
y_2016_tohel['time'] = y_2016_tohel['tunti'].apply(lambda x: pd.to_timedelta(x, unit='h'))
y_2016_tolaru['time'] = y_2016_tolaru['tunti'].apply(lambda x: pd.to_timedelta(x, unit='h'))
y_2016_tolaru = y_2016_tolaru.set_index('time')
y_2016_tohel = y_2016_tohel.set_index('time')
y_2016_tohel
y_2016_tohel = y_2016_tohel.drop(['tunti'], axis = 1)
y_2016_tolaru = y_2016_tolaru.drop(['tunti'], axis = 1)
y_2016_tolaru
xinterval = pd.date_range('1/1/2011', periods=24, freq='H').time
plt.figure(figsize=(23,13))
plt.xticks(xinterval,rotation=45)
plt.grid(True)
plt.title('Traffic towards Lauttasaari. Representative sample from 2016, 1 hour sample interval')
plt.plot(xinterval,y_2016_tolaru['light traffic']);
plt.plot(xinterval,y_2016_tolaru['heavy traffic']);
plt.plot(xinterval,y_2016_tolaru['buses']);
plt.legend(['light traffic','heavy traffic','buses']);
plt.xlabel('Time');
plt.ylabel('Vehicles / hour');
plt.figure(figsize=(23,13))
plt.xticks(xinterval,rotation=45)
plt.grid(True)
plt.title('Traffic towards Helsinki. Representative sample from 2016, 1 hour sample interval')
plt.plot(xinterval,y_2016_tohel['light traffic']);
plt.plot(xinterval,y_2016_tohel['heavy traffic']);
plt.plot(xinterval,y_2016_tohel['buses']);
plt.legend(['light traffic','heavy traffic','buses']);
plt.xlabel('Time');
plt.ylabel('Vehicles / hour');
y_2016_tohel.to_csv('data/dist_larubridge_tohel_16.csv')
y_2016_tolaru.to_csv('data/dist_larubridge_tolaru_16.csv')
Explanation: Lets define light as: ha=henkilöautot pa=pakettiautot mp=moottoripyörät
Heavy as: ka=kuorma-autot ra=rekka-autot 
Buses as: la=linja-autot
End of explanation
<END_TASK>