How to create a lambda function to return next cell value?

Question:

For example :

Val1 Val2
48 21
156 45
61 54
12 79
64 45

the excepted output is the followwing :

Val1 Val2 Output
48 21 45
156 45 54
61 54 79
12 79 45
64 45

What I did try is the following but it does not work and I am not sure if it is possible to do with lambda.
)
)

DF["Output"] = DF.apply(lambda x: x[1].val2, axis=1)

The final goal is to apply thanks to a lambda function the following calculation :

(21/45)
(45/54)
(54/79)
(79/45)

Wihtout having to create a new column with the shifted values as suggested in Ynjxsjmh Answer

Asked By: TourEiffel

||

Answers:

Using Series.shift(-1)

DF["Output"] = DF["Val2"].shift(-1)
Answered By: Ynjxsjmh
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.