In [1]:
import warnings
import itertools
import pandas
import math
import sys
import os
import numpy as np
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
init_notebook_mode(connected=True)



In [2]:
# Add your data file to plot
data_file = "../data/realTweets/Twitter_volume_AAPL.csv"

In [3]:
# Plot Data (Note if the plot is not visible please close the tab shutdown notebook and restart)
Error = None
if os.path.isfile(data_file):
    dataframe = pandas.read_csv(data_file)
else:
    Error = "No such file : "+data_file
    print(Error)
if set(['timestamp','value']).issubset(dataframe.columns) and Error is None:
    x = np.array(dataframe['timestamp'])
    y = np.array(dataframe['value'])
    mean = np.mean(y)

    trace = {"x": x,
             "y": y,
             "mode": 'lines',
             "name": 'Value'}
    trace_mean = {"x": x,
                  "y": np.ones(len(x))*mean,
                  "mode": 'lines',
                  "name": 'Mean'}
    traces = [trace,trace_mean]
    layout = dict(title = "Data plot : "+data_file,
                  xaxis = dict(title = 'X'),
                  yaxis = dict(title = 'Value')
                 )
    fig = dict(data=traces, layout=layout)
    iplot(fig)
else:
    if Error is None:
        Error = "Missing colomns in file "+data_file
    print(Error)



In [ ]: