Reputation: 1
I'm trying to make a graph of the first column ('Time') of a csv file plotted against the the second column ('Bid').
Here's what I have so far.
import pandas as pd
import datetime
import csv
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
headers = ['Time','Bid','Ask']
df = pd.read_csv('quotes_format.csv')
x = df['Time']
y = df['Bid']
plt.plot(x,y)
plt.gcf().autofmt_xdate()
plt.show()
The csv file looks something like this
This fails and returns exit code 1. How would I fix this so it would generate the graph I'm looking for?
Upvotes: 0
Views: 43
Reputation: 13
You can specify what the names of each column in the dataframe are with the parameter names
.
headers = ['Time','Bid','Ask']
df = pd.read_csv('quotes_format.csv', names=headers)
Here is the documentation for the pandas read_csv function.
Upvotes: 1