Python Two-Dimensional Array Question

Asked 2 years ago, Updated 2 years ago, 14 views

The one-dimensional arrays of a,b,c,d,e,f, as shown in the source below ["5", "Submission", "Second Year", "date00", "Park Chulsoo", "Task 1] ["4", "Submit", "First Year", "date00", "Kim Chulsoo", "Task 2"] ["3", "Closing", "Junior", "Date00", "Lee Chulsoo", "Task 3"] ["2", "Submit", "Previous Year", "date00", "Kim Younghee", "Assignment 4"] ["1", "Closing", "Second Year", "date00", "Park Younghee", "Assignment 5"] It's made of this two-dimensional arrangement.

Then, only 'submission' and 'second grade' are included in that arrangement ["5", "Submit", "Second year", "date00", "Park Chulsoo", "Task 1] I'll just pick one I want to select only 'date00' and 'task 1' and store them in one variable (like res='task1'+'date00) First of all, I found the part that included 'second grade' in the for door below and put it in the rlsts. But that's the way it is [array (['5', 'submission', 'second grade', 'date00', 'Park Chul-soo', 'task 1'), dtype='<U6', array (['1', 'deadline', 'second grade', 'date00', 'Park Young-hee', 'task 5', dtype='<U6')] I don't know why the array and dtype are formed.

import numpy as np
a=['5','4','3','2','1']
b=["Submission", "Submission", "Closing", "Submission", "Closing"]
c=["Second Year", "First Year", "Third Year", "Previous Year", "Second Year"]
d=['date00','date00','date00','date00','date00']
e=[Park Chul-soo, Kim Chul-soo, Lee Chul-soo, Kim Young-hee, Park Young-hee]
f=["Task 1", "Task 2", "Task 3", "Task 4", "Task 5"]
a=np.array([a])
a1=a.reshape((5,1))
b=np.array([b])
b1=b.reshape((5,1))
c=np.array([c])
c1=c.reshape((5,1))
d=np.array([d])
d1=d.reshape((5,1))
e=np.array([e])
e1=e.reshape((5,1))
f=np.array([f])
f1=f.reshape((5,1))
lsts=np.hstack([a1,b1,c1,d1,e1,f1])
rlsts=[]
for lst in lsts:
    If 'second grade' inst:
        rlsts.append(lst)

print(rlsts)

python

2022-09-21 10:05

1 Answers

It's because you made it into a numpy array.

To change the numpy array to list, do the following.

for lst in lsts:
    If 'second grade' inst:
        rlsts.append(list(lst))


2022-09-21 10:05

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.