Reputation: 2109
I am doing a time series analysis:
interval_data_file.csv
is a csv file, with two columns: Time
and Freq
.
import pandas as pd
import datetime
import numpy as np
import matplotlib.pylab as plt
from matplotlib.pylab import rcParams
rcParams['figure.figsize'] = 300, 20
DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
INPUT_FILE = 'interval_data_file.csv'
dateparse = lambda dates: pd.datetime.strptime(dates, DATETIME_FORMAT)
data = pd.read_csv(INPUT_FILE, parse_dates=True, index_col='Time',
date_parser=dateparse)
print data.index
ts = data['Freq']
#print ts.head(10)
print ts['1970-02-04 20:12:16']
plt.plot(ts)
plt.show()
This is the plot outputted which is obviously wrong:
Can someone suggest what I am doing wrong?
Upvotes: 0
Views: 223
Reputation: 506
I think the issue is that you are not sorting your index. Try:
data.sort_index(inplace=True)
Upvotes: 2