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)

CodePudding user response:

The
reference 3 floor cclxpp123 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]


In fact has been plagued the problem is, without the aid of list comprehensions, why cannot be the same again for loop results [] ~ ah ~

CodePudding user response:

The
YeYe reference 4 floor?? Response:
hello, here 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)

Is your code can't print the last line? How did your image data, others?

CodePudding user response:

refer to 6th floor cclxpp123 response:
Quote: YeYe reference 4 floor?? Response:
hello, here 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)

Is your code can't print the last line? Then how is your image data to, others.


Is my code, I don't know how to print the last line or any refer ~ ~ thank you!

CodePudding user response:

Exactly is "just can't print the last line," or "can't print any line", completely didn't know (and the initial problem of what to do with you also don't know). If the former, should be the problems setting up the border, you need to pay attention to, only fitting n - 1 n interval time, isn't the problem; If the latter, suggests that pp is nothing inside, should be your calculation process or function call has a problem. I suggest you to restart a problem, the data summary, the key code, variables (such as the f, item these completely unclear) and what are you going to do to make it clear, see if someone else can help you.
  • Related