#!/usr/bin/env python # coding: utf-8 # In[20]: import pandas as pd, numpy as np import matplotlib.pyplot as plt get_ipython().run_line_magic('matplotlib', 'inline') # In[21]: df=pd.read_csv('2013_2017_monthly_BUD_traffic.csv',encoding='latin-1',sep=';') # In[25]: df['LF']=df[' PAX']/df['Capacity'] # In[27]: df.plot(kind='scatter',x='ATM',y='LF') # In[31]: 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) # In[46]: dz=df.groupby(['Year','City']).sum() dz['LF']=dz[' PAX']/dz['Capacity'] # In[58]: 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"} } } # In[59]: iplot(fig, filename='plot1') # In[63]: import numpy as np # In[74]: 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') # In[ ]: # In[ ]: