Skip to content

Instantly share code, notes, and snippets.

@kamath
Created January 9, 2016 23:19
Show Gist options
  • Save kamath/2f62fa4284c2ad6489b8 to your computer and use it in GitHub Desktop.
Save kamath/2f62fa4284c2ad6489b8 to your computer and use it in GitHub Desktop.
import sqlite3 as lite
import sys
import matplotlib
import pylab
import numpy as np
import matplotlib.pyplot as plt
/*
code to populate array here
*/
#x is an array of integers, and y is an array of floats
plt.plot(x,y)
xcoords = np.array(x)
ycoords = np.array(y)
fit = np.polyfit(xcoords, ycoords, -1)
plt.show()
/*
I get an error when I run this saying
Traceback (most recent call last):
File "percent.py", line 26, in <module>
fit = np.polyfit(xcoords, ycoords, -1)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/lib/polynomial.py", line 542, in polyfit
x = NX.asarray(x) + 0.0
TypeError: unsupported operand type(s) for +: 'numpy.ndarray' and 'float'
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment