0

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?

1 Answer 1

1

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.

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.