IPython console OK X Direct Execution Error. All in Windows 10.

22 views
Skip to first unread message

Willians de Carvalho Marcos

unread,
Jul 3, 2017, 8:39:33 PM7/3/17
to spyder

In Spyder 3.1.4, when I execute my code step by step, via Shift + Enter in IPython console, I have no problem, execution is fast and I get the expected results.

Python version 3.6.1 |Anaconda custom (64-bit)| (default, May 11 2017, 13:25:24) [MSC v.1900 64 bit (AMD64)]

Pandas version: 0.20.1

       for a1 in range(ei, ef):

           ab = a1 - ei

           a2 = a_s[ab]

           l2 = len(ax.loc[(ax.Baid == a2), co].values)

           print('c= {} ei = {:>8d} a1= {:>8d} ab= {:>4d} a2= {:>4d}\

l2= {:>4d} '.format(c, ei, a1, ab, a2, l2))

           dfb.loc[a1, 'Kaid'] = ax.loc[az[ab], 'Baid']

           dfb.loc[a1, 'Ecam'] = ax.loc[(ax.Baid == a2), co].values

           dfb.loc[a1, 'Laie'] = ax.loc[(ax.Baid == a2), 'sq'].values

c= Cqqtd ei =   263856 a1=   263856 ab=    0 a2=    8l2=    1

c= Cqqtd ei =   263856 a1=   263857 ab=    1 a2=    9l2=    1

c= Cqqtd ei =   263856 a1=   263858 ab=    2 a2=   39l2=    1

c= Cqqtd ei =   263856 a1=   263859 ab=    3 a2=   47l2=    1

c= Cqqtd ei =   263856 a1=   263860 ab=    4 a2=   57l2=    1

c= Cqqtd ei =   263856 a1=   263861 ab=    5 a2=   59l2=    1

 

However, when I try to execute it via Execution Options, the above code fails;


c= Cqqtd ei =    -4278 a1=    -4278 ab=    0 a2=    0 l2=    0


Traceback (most recent call last):

  File "E:\src\dev\MTR050020.py", line 241, in <module>

    main()

  File "E:\src\dev\MTR050020.py", line 188, in main

    dfb = setbest(dfa, dfb, cab)

  File "E:\src\dev\MTR050020.py", line 64, in setbest

    dfb.loc[a1, 'Ecam'] = ax.loc[(ax.Baid == a2), co].values

  File "C:\cf\lib\site-packages\pandas\core\indexing.py", line 179, in __setitem__

    self._setitem_with_indexer(indexer, value)

  File "C:\cf\lib\site-packages\pandas\core\indexing.py", line 579, in _setitem_with_indexer

    raise ValueError('Must have equal len keys and value '

ValueError: Must have equal len keys and value when setting with an iterable


The value of the variable ei goes crazy.

Why does this occur?

Reply all
Reply to author
Forward
0 new messages