Home > other > The Python for loop results into a column
The Python for loop results into a column
Time:01-29
As shown in figure, the result of the for loop formed many columns, how to translate them into a list? Is make [1, 2, 3] [4 and 6] [6]
CodePudding user response:
That's all columns in the same [] ~
CodePudding user response:
Don't have to list comprehensions/... for... How to put the data in the same column?
CodePudding user response:
a, b, c=[1, 2], [3, 4], [5]
D=[]
[d.e xtend (x) for x in (a, b, c)] Out [218] : [None, None, None]
Print (d) [1, 2, 3, 4, 5]
CodePudding user response:
Hello, know a=[1, 2], but the result of the for loop out I don't know how to print out the last line, such as in the picture [1.47, 5.21, 10.66] this line, I how can't print out, part of my code is like this:
for I in range (cols) : Lr=LinearRegression () F=lr. Fit (x [I * ys: I * ys + xs], y [I * ys: I * ys + xs]) P=lr. Predict (the test [xs ys: (xs and ys) + + I * I * ys]) Pp=[j for the item in the for j p in item] Print (pp)