-1

I need to clean some data and I want to know what the most efficient way to go about it. For the data I have i'm missing about 3 yrs of open data, its been replaced with all zero's. I would like to replace these zero by the value of the earlier close.

enter image description here

Chris Albert
  • 2,462
  • 8
  • 27
  • 31

1 Answers1

0
for i in range(len(df)-1):
    df.Open.iloc[i]=df.Close.iloc[i-1]

you neede dto assign for each open the previous close

Ran A
  • 746
  • 3
  • 7
  • 19