Hi I keep getting a syntax error but I cant figure out why. My code is
data = numpy.loadtxt((etf + '.csv',dtype = ([("date", "S8"), ("value", "f8")]), delimiter= ',' , usecols=(0,-1)))
x = numpy.arange(len(data))
pl1.bar(x,data["value"], width = 0.8)
p1.xticks(x+.4, data["date"])
p1.show()
and the syntax error is
data = numpy.loadtxt((etf + '.csv',dtype = ([("date", "S8"), ("value", "f8")]), delimiter= ',' , usecols=(0,-1)))
^
Thanks
Once you get to here, Python thinks you’re building a tuple to send as one argument to
loadtxt, rather than sending multiple arguments. So,errors because the
=isn’t valid in a tuple. You probably meant to do this:But the extra brackets around
etf + '.csv'aren’t needed here – the string concatenation takes precedence anyway, so you can just remove the second(and everything will work.