I got an error TypeError: zip argument #2 must support iteration.
data = libraries.pd.read_csv('a.csv',header=1, parse_dates=True)
datas = DataCleaning.DataCleaning(data)
datas.cleaning(media)
calDf = datas.getDatas()
array_x = libraries.np.int32(libraries.np.zeros(len(calDf)))
array_y = libraries.np.int32(libraries.np.zeros(len(calDf)))
if len(calDf) > 1:
for num in range(len(calDf)):
array_x[num] = calDf.iloc[num,0]
array_y[num] = calDf.iloc[num,1]
def nonlinear_fit(x,a,b):
return b * libraries.np.exp(x / (a+x))
prameter_initial = libraries.np.array([0,0])
try:
param, cov = libraries.curve_fit(nonlinear_fit, array_x, array_y, maxfev=5000)
except RuntimeError:
print("Error - curve_fit failed")
li_result = []
li_result = zip(y, array_x, array_y)
I think the part of zip(y, array_x, array_y)
is wrong because zip's arguments are not list type,so I wrote
for i in y:
li_result = []
li_result = zip(y, array_x[i], array_y[i])
but I got an error,
li_result = zip(y, array_x[i], array_y[i])
IndexError: only integers, slices (`:`), ellipsis (`...`),
numpy.newaxis (`None`) and integer or boolean arrays are valid indices
So, I cannot understand how to fix this. What should I do?
It sounds like you have three arrays itemNameList
, array_x
, and array_y
Assuming they are all the same shape, you can just do:
zipped = zip(itemNameList,array_x,array_y)
li_result = list(zipped)
EDIT
Your problem is that array_x
and array_y
are not actual numpy.array
objects, but likely numpy.int32
(or some other non-iterable) objects:
array_x = np.int32(np.zeros(None))
array_x.shape
# ()
array_x.__iter__
# AttributeError: 'numpy.int32' object has no attribute '__iter__'
Perhaps their initialization is not going as expected, or they are being changed from arrays somewhere in your code?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With