import pandas as pd, numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
df=pd.read_csv('2013_2017_monthly_BUD_traffic.csv',encoding='latin-1',sep=';')
df['LF']=df[' PAX']/df['Capacity']
df.plot(kind='scatter',x='ATM',y='LF')
<matplotlib.axes._subplots.AxesSubplot at 0x2006dea07f0>
import plotly.plotly as py
import plotly.tools as tls
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
init_notebook_mode(connected=True)
dz=df.groupby(['Year','City']).sum()
dz['LF']=dz[' PAX']/dz['Capacity']
fig = {
'data': [
{
'x': dz.loc[2013]['ATM'],
'y': dz.loc[2013]['LF'],
'text': dz.loc[2013].index,
'mode': 'markers',
'name': '2013'},
{
'x': dz.loc[2017]['ATM'],
'y': dz.loc[2017]['LF'],
'text': dz.loc[2017].index,
'mode': 'markers',
'name': '2017'},
{
'x': dz.loc[2015]['ATM'],
'y': dz.loc[2015]['LF'],
'text': dz.loc[2015].index,
'mode': 'markers',
'name': '2015'}
],
'layout': {
'xaxis': {'title': 'ATM','type':'log'},
'yaxis': {'title': "LF"}
}
}
iplot(fig, filename='plot1')
import numpy as np
fig = {
'data': [
{
'x': dz.loc[2013]['ATM']/365*(1+np.random.randn(len(dz.loc[2013]))),
'y': dz.loc[2013]['LF'],
'text': dz.loc[2013].index,
'mode': 'markers',
'name': '2013'},
{
'x': dz.loc[2017]['ATM']/365*(1+np.random.randn(len(dz.loc[2017]))),
'y': dz.loc[2017]['LF'],
'text': dz.loc[2017].index,
'mode': 'markers',
'name': '2017'},
{
'x': dz.loc[2015]['ATM']/365*(1+np.random.randn(len(dz.loc[2015]))),
'y': dz.loc[2015]['LF'],
'text': dz.loc[2015].index,
'mode': 'markers',
'name': '2015'}
],
'layout': {
'xaxis': {'title': 'ATM','type':'log'},
'yaxis': {'title': "LF"}
}
}
iplot(fig, filename='plot1')