Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python using Pandas Data frame only: How can we iterate through rows of a column and divide previous row by following row throughout the

In Python using Pandas Data frame only:

How can we iterate through rows of a column and divide previous row by following row throughout the table:

eg: Focusing on columns close and AdjClose

close on dec 28,2018 (113.03) divided by close on dec 27,2018 (113.78) = 0.99340833

Adj close on dec 28,2018 (101.3) divided by close on dec 27,2018 (101.80) = 0.99341847

Then substract the result from Close from the result of Adj close (result to be stored in a new column)

image text in transcribed

Date Open High Low Close* Adj Close** Dec 28, 2018 114.22 114.80 112.50 113.03 101.13 Dec 27, 2018 109.99 113.78 109.47 113.78 101.80 Dec 26, 2018 108.00 111.39 105.94 111.39 99.66 Dec 24, 2018 109.90 111.00 107.50 107.57 96.25 Dec 21, 2018 112.50 115.28 110.44 110.94 99.26 Dec 20, 2018 115.70 116.45 111.70 113.02 101.12 Dec 19, 2018 117.15 120.27 115.97 116.43 104.17 Dec 18, 2018 116.90 118.23 116.02 116.65 104.37 Dec 17, 2018 119.07 119.78 115.07 116.10 103.88 Dec 14, 2018 119.50 121.11 119.44 119.90 107.28 Dec 13, 2018 121.26 121.79 120.17 120.73 108.02 Dec 12, 2018 122.51 122.88 121.00 121.16 108.41 Dec 11, 2018 123.25 123.81 120.00 120.89 108.16

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions

Question

What are the main differences between rigid and flexible pavements?

Answered: 1 week ago

Question

What is the purpose of a retaining wall, and how is it designed?

Answered: 1 week ago

Question

How do you determine the load-bearing capacity of a soil?

Answered: 1 week ago

Question

what is Edward Lemieux effect / Anomeric effect ?

Answered: 1 week ago

Question

5. Develop a self-management module for a training program.

Answered: 1 week ago