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 numpy array is formed from 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 = []
# to divide into training & test, I am putting line 10th and 11th in test set
count = 0
for line in chuk:
# Converting strings to numpy arrays
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
# Create linear regression object
regr = linear_model.LinearRegression()
# Train the model using the training sets
regr.fit(training_set_feature_list, training_set_label_list)
#print test_set_feature_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 the numpy array that I want to join with two python lists
First python list is company which looks like this:
['OT', 'OT', 'OT', 'OT',....]
Second python list is state:
['Alabama', 'Alabama', 'Alabama', 'Alabama', ...]
Now what I am trying to do is form one list which has 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 added array and [] around array elements):
('OT', 'Alabama', array([729, 733]))
('OT', 'Alabama', array([124, 122]))
How do I join these lists and array so as to form one list which does not have above issue?
print(array1)and update its result?