I have two python lists and a numpy array. The numpy array looks like this:
[array([93495052.969556, 98555123.061462])]
[array([1000976814.605984, 998276347.359732])]
[array([6868127850.435482, 6903911250.620625])]
[array([775127467.947004, 802369832.938230])]
This one numpy arrayis formed from the following code:
array1 = []
company = []
state = []
def process_chunk(chuk):
training_set_feature_list = []
training_set_label_list = []
test_set_feature_list = []
test_set_label_list = []
np.set_printoptions(suppress=True)
array2 = []
count = 0
for line in chuk:
if count == 9:
test_set_feature_list.append(np.array(line[3:4],dtype = np.float))
test_set_label_list.append(np.array(line[2],dtype = np.float))
company.append(line[0])
state.append(line[1])
elif count == 10:
test_set_feature_list.append(np.array(line[3:4],dtype = np.float))
test_set_label_list.append(np.array(line[2],dtype = np.float))
else:
training_set_feature_list.append(np.array(line[3:4],dtype = np.float))
training_set_label_list.append(np.array(line[2],dtype = np.float))
count += 1
regr = linear_model.LinearRegression()
regr.fit(training_set_feature_list, training_set_label_list)
array2.append(np.array(regr.predict(test_set_feature_list),dtype = np.float))
np.set_printoptions(formatter={'float_kind':'{:f}'.format})
for items in array2:
array1.append(items)
array1 is a numpy array that I want to combine with two python lists
The first python list is equal company, which looks like this:
['OT', 'OT', 'OT', 'OT',....]
The second python list is state:
['Alabama', 'Alabama', 'Alabama', 'Alabama', ...]
Now what I'm trying to do is form one list, which has the following structure:
('OT', 'Alabama', 729, 733)
('OT', 'Alabama', 124, 122)
('OT', 'Arizona', 122, 124)
I wrote this line of code - final_list = zip(company,state,array1)but this produces this output (with the addition arrayand []around the elements of the array):
('OT', 'Alabama', array([729, 733]))
('OT', 'Alabama', array([124, 122]))
How to join these lists and an array to form one list that does not have a problem?