0

I am doing a time series analysis:

interval_data_file.csv is a csv file, with two columns: Time and Freq.

enter image description here

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:

enter image description here

Can someone suggest what I am doing wrong?

2
  • Why do you think the output plot is wrong? Looking at your data, it seems pretty correct. Commented Dec 17, 2016 at 13:55
  • Since you already have frequency counts, did you give bar plot a try which seems ideal for such a purpose and see if you get the right results? You need to do - plt.bar(ts.index, ts) if you intend on doing via matplotlib. Commented Dec 17, 2016 at 13:56

1 Answer 1

2

I think the issue is that you are not sorting your index. Try:

data.sort_index(inplace=True)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.