Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Merge rows of 2 arrays
#1
Hello,

I have 2 arrays: time[1,2,3,4,5,] and data[0, 9, -15, 5, -2245]

I want combine these 2 arrays in such a way that I get a single array in the following format:
[1 0
2 9
3 -15
4 5
5 -2245]

Please guide
Reply
#2
uze built-in zip() function
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
#Here you go
list1=[1,2,3,4,5]
list2=[0,9,-15,5,-2245]
list3=[]
for i in range(0,5):
list3.append(list1[i])
list3.append(list2[i])
print(list3)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  The code I have written removes the desired number of rows, but wrong rows Jdesi1983 0 1,602 Dec-08-2021, 04:42 AM
Last Post: Jdesi1983
  Pandas DataFrame combine rows by column value, where Date Rows are NULL rhat398 0 2,083 May-04-2021, 10:51 PM
Last Post: rhat398
  Indexing [::-1] to Reverse ALL 2D Array Rows, ALL 3D, 4D Array Columns & Rows Python Jeremy7 8 6,963 Mar-02-2021, 01:54 AM
Last Post: Jeremy7
  merge two dataframes with different number of rows dawid294 5 3,983 Feb-05-2021, 03:21 PM
Last Post: perfringo
  Merge 2 dataframes but avoid double summing of rows? vinaysalian17 0 1,819 Jun-03-2020, 01:48 AM
Last Post: vinaysalian17

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020