Note that there are some explanatory texts on larger screens.

plurals
  1. PONested for loops, delete dictionary temporary inside the loop
    primarykey
    data
    text
    <pre><code>bb = {} ss = {} for i in range(5): # i are the different days for row in ps: # ps = different dataframes a=row[i:i+1] DE = a['Daily_Error'][0] Date = a.index[0] Identifier = (a.columns[0],a.columns[1]) if DE &gt; 1 : if format(Identifier) in ss: ss[format(Identifier)].append([np.log(Price1)]) else: ss[format(Identifier)]=[np.log(Price1)] print 'YES', format(Date) if xy &lt; -0.006: print 'STOP' ss.clear() bb.clear() bb = {} ss = {} break </code></pre> <p>I would like to break the inner loop when xy&lt;-0.006 and continue with the outer loop [i+1]. Additionally, I would like to delete the dictionary bb, ss and fill them during the next loop. However, this is not working. How can I circumvent the problem without rewriting the whole code or using another data structure?</p> <p>FYI: the break works when I just use:</p> <pre><code> if xy &lt; -0.006: print 'STOP' break </code></pre> <p>Considering the first 4 Days I get:</p> <pre><code>YES 2005-09-19 00:00:00 0 YES 2005-09-19 00:00:00 0 YES 2005-09-19 00:00:00 0 YES 2005-09-20 00:00:00 STOP YES 2005-09-21 00:00:00 0 YES 2005-09-19 00:00:00 0 YES 2005-09-19 00:00:00 0 YES 2005-09-22 00:00:00 YES 2005-09-20 00:00:00 STOP YES 2005-09-23 00:00:00 0 YES 2005-09-19 00:00:00 0 YES 2005-09-19 00:00:00 0 </code></pre> <p>Why does the iteration start at 2005-09-19 again?</p> <p>EDIT2: Narrowed down the issue! The issue is indeed that code-block: </p> <pre><code> if DE &gt; 1 : </code></pre> <p>But why does the code start at iteration zero if I break the inner loop? and it only happens after I delete bb and ss... I do not understand it , sorry!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload