0

I have a script in python that does some non-linear optimization and I am having now a somewhat dumb error. I did a loop on the script and now I what it to save the results in a variable called "Final", which at the begining I create as a dummy by setting it to None. So now if it is the first iteration, it will be an empty variable where my results (a pandas DataFrame) will be saved, if it is after the first iteration, the result will be appended to the last "Final" variable.

This is my code:

if Final == None:
    Final = df  #df is a pandas dataframe of 1 line and 29 columns
elif Final != None:
    Final = Final.append(df,ignore_index = True)

And I get this error: "unindent does not match any outer indentation level"

Am I wrong in setting the Final variable as None? Is there a better way to add the results to a final variable?

PM 2Ring
  • 54,345
  • 6
  • 82
  • 182
LuisCol8
  • 69
  • 10

0 Answers0