vendredi 27 mars 2015

How Do I Combine Multiple Lists Horizontally In Python?

I have searched up and down for this in python and could not find exactly what I'm looking for.


Suppose I have the following example:



date_list = [Mar 27 2015, Mar 26 2015, Mar 25 2015]
num_list_1 = [22, 35, 7]
num_list_2 = [15, 12, 2]


How do I combine the lists so my end result is something like this:



combined_list = [Mar 27 2015, 22, 15
Mar 26 2015, 35, 12
Mar 25 2015, 7, 2]


Once I have the data in the combined_list variable, I want to be able to pass it to a for loop and iterate over each line and insert it into my SQLite db if the date does not exist or update the existing record if the date is found.


I have my separate lists and I have the database insert working. What I'm not sure about is the proper way to combine the lists. Am I looking for a pandas dataframe? Or something else?


Any pointers to nudge me in the right direction would be appreciated


Aucun commentaire:

Enregistrer un commentaire