I am trying to read a csv file using pandas. The CSV file is structured as follows:
Timestamp, UTC, id, loc, spd
001, 12z, q20, "52, 13", 320
002, 13z, a32, "53, 12", 321
003, 14z, q32, "54, 11", 321
004, 15`, a43, "55, 10", 330
The code I am using is as follows:
import pandas as pd
import matplotlib.pyplot as plt
fname = "data.csv"
data = pd.read_csv(fname,sep=",", header=None, skiprows=1)
data.columns = ["Timestamp", "UTC", "Callsign", "Position", "Speed", "Direction"]
t = data["Timestamp"]
utc = data["UTC"]
acid = data["Callsign"]
pos = data["Position"]
spd = ["Speed"]
plt.plot(t,spd)
plt.show()
How do I deal with the loc column being two values inside double brackets " ", such that I can plot the timestamp vs spd for example?
When I try to plot(t,id), it goes fine, but when I try to plot(t, spd), I get a ValueError (x and y must have same first dimension, but have shapes (466,) and (1,)?
Anyone know a workaround for this?