IndexError: boolean index did not match indexed array along dimension 1; dimension is 2 but corresponding boolean dimension is 1 Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!IndexError - 'List Index out of Range'Odd and Unexpected “IndexError: pop index out of range”IndexError: list index out of range python — 3.4.3Indexerror: Tuple index out of rangleOneHotEncoding raises IndexError: arrays used as indices must be of integer (or boolean) typePython IndexError: list assignment index out of rangeWhat is 'IndexError: list index out of range'?Python 3.6 - IndexError: list index out of rangeIndexError('list assignment index out of range')IndexError: list index out of range in if

Sum letters are not two different

How fail-safe is nr as stop bytes?

Is grep documentation about ignoring case wrong, since it doesn't ignore case in filenames?

Why do we bend a book to keep it straight?

Morning, Afternoon, Night Kanji

Is it possible for SQL statements to execute concurrently within a single session in SQL Server?

Is there any word for a place full of confusion?

Is there hard evidence that the grant peer review system performs significantly better than random?

Sending unknown callers to voice mail automatically?

Converted a Scalar function to a TVF function for parallel execution-Still running in Serial mode

The code below, is it ill-formed NDR or is it well formed?

What would you call this weird metallic apparatus that allows you to lift people?

Time to Settle Down!

Most bit efficient text communication method?

How does light 'choose' between wave and particle behaviour?

SF book about people trapped in a series of worlds they imagine

Do I really need to have a message in a novel to appeal to readers?

Is it fair for a professor to grade us on the possession of past papers?

An adverb for when you're not exaggerating

How do living politicians protect their readily obtainable signatures from misuse?

Significance of Cersei's obsession with elephants?

Should I use a zero-interest credit card for a large one-time purchase?

Why do we need to use the builder design pattern when we can do the same thing with setters?

Can the Great Weapon Master feat's damage bonus and accuracy penalty apply to attacks from the Spiritual Weapon spell?



IndexError: boolean index did not match indexed array along dimension 1; dimension is 2 but corresponding boolean dimension is 1



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!IndexError - 'List Index out of Range'Odd and Unexpected “IndexError: pop index out of range”IndexError: list index out of range python — 3.4.3Indexerror: Tuple index out of rangleOneHotEncoding raises IndexError: arrays used as indices must be of integer (or boolean) typePython IndexError: list assignment index out of rangeWhat is 'IndexError: list index out of range'?Python 3.6 - IndexError: list index out of rangeIndexError('list assignment index out of range')IndexError: list index out of range in if



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have below arrays:



X = np.array([[68. , 21.5],[71. , 23.5],[ 73. , 22.5 ],[ 64. , 18. ],[ 68. , 23.5],
[ 65, 20. ]])


T=np.array(['Female','Male','Male','Female','Female','Male'])



Y=np.array([[9],[8],[9],[9],[8],[8]], dtype='uint8')


I am trying to find statistics using lambda function as below:



Stats1=lambda X,T:[[np.mean(x),np.std(x,ddof=1),len(x)] for x in [X[T=='Female'],[X[T=='Male']]]]
Stats2=lambda X,Y:[[np.mean(x),np.std(x,ddof=1),len(x)] for x in [X[Y==9],[X[Y==8]]]]


Stats1 works fine:



[[muF,sigmaF,NF],[muM,sigmaM,NM]]=Stats1(X,T)


But Stats2 gives error:



[[muP,sigmaP,NP],[muN,sigmaN,NN]]=Stats2(X,Y)

---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-20-3678a0bdbb43> in <module>()
----> 1 [[muP,sigmaP,NP],[muN,sigmaN,NN]]=Stats2(X,Y)

<ipython-input-18-940d7bad1eef> in <lambda>(X, Y)
----> 1 Stats2=lambda X,Y:[[np.mean(x),np.std(x,ddof=1),len(x)] for x in [X[Y==9],[X[Y==8]]]]

IndexError: boolean index did not match indexed array along dimension 1; dimension is 2 but corresponding boolean dimension is 1


Can anyone help me understand why and how to fix it.










share|improve this question




























    0















    I have below arrays:



    X = np.array([[68. , 21.5],[71. , 23.5],[ 73. , 22.5 ],[ 64. , 18. ],[ 68. , 23.5],
    [ 65, 20. ]])


    T=np.array(['Female','Male','Male','Female','Female','Male'])



    Y=np.array([[9],[8],[9],[9],[8],[8]], dtype='uint8')


    I am trying to find statistics using lambda function as below:



    Stats1=lambda X,T:[[np.mean(x),np.std(x,ddof=1),len(x)] for x in [X[T=='Female'],[X[T=='Male']]]]
    Stats2=lambda X,Y:[[np.mean(x),np.std(x,ddof=1),len(x)] for x in [X[Y==9],[X[Y==8]]]]


    Stats1 works fine:



    [[muF,sigmaF,NF],[muM,sigmaM,NM]]=Stats1(X,T)


    But Stats2 gives error:



    [[muP,sigmaP,NP],[muN,sigmaN,NN]]=Stats2(X,Y)

    ---------------------------------------------------------------------------
    IndexError Traceback (most recent call last)
    <ipython-input-20-3678a0bdbb43> in <module>()
    ----> 1 [[muP,sigmaP,NP],[muN,sigmaN,NN]]=Stats2(X,Y)

    <ipython-input-18-940d7bad1eef> in <lambda>(X, Y)
    ----> 1 Stats2=lambda X,Y:[[np.mean(x),np.std(x,ddof=1),len(x)] for x in [X[Y==9],[X[Y==8]]]]

    IndexError: boolean index did not match indexed array along dimension 1; dimension is 2 but corresponding boolean dimension is 1


    Can anyone help me understand why and how to fix it.










    share|improve this question
























      0












      0








      0








      I have below arrays:



      X = np.array([[68. , 21.5],[71. , 23.5],[ 73. , 22.5 ],[ 64. , 18. ],[ 68. , 23.5],
      [ 65, 20. ]])


      T=np.array(['Female','Male','Male','Female','Female','Male'])



      Y=np.array([[9],[8],[9],[9],[8],[8]], dtype='uint8')


      I am trying to find statistics using lambda function as below:



      Stats1=lambda X,T:[[np.mean(x),np.std(x,ddof=1),len(x)] for x in [X[T=='Female'],[X[T=='Male']]]]
      Stats2=lambda X,Y:[[np.mean(x),np.std(x,ddof=1),len(x)] for x in [X[Y==9],[X[Y==8]]]]


      Stats1 works fine:



      [[muF,sigmaF,NF],[muM,sigmaM,NM]]=Stats1(X,T)


      But Stats2 gives error:



      [[muP,sigmaP,NP],[muN,sigmaN,NN]]=Stats2(X,Y)

      ---------------------------------------------------------------------------
      IndexError Traceback (most recent call last)
      <ipython-input-20-3678a0bdbb43> in <module>()
      ----> 1 [[muP,sigmaP,NP],[muN,sigmaN,NN]]=Stats2(X,Y)

      <ipython-input-18-940d7bad1eef> in <lambda>(X, Y)
      ----> 1 Stats2=lambda X,Y:[[np.mean(x),np.std(x,ddof=1),len(x)] for x in [X[Y==9],[X[Y==8]]]]

      IndexError: boolean index did not match indexed array along dimension 1; dimension is 2 but corresponding boolean dimension is 1


      Can anyone help me understand why and how to fix it.










      share|improve this question














      I have below arrays:



      X = np.array([[68. , 21.5],[71. , 23.5],[ 73. , 22.5 ],[ 64. , 18. ],[ 68. , 23.5],
      [ 65, 20. ]])


      T=np.array(['Female','Male','Male','Female','Female','Male'])



      Y=np.array([[9],[8],[9],[9],[8],[8]], dtype='uint8')


      I am trying to find statistics using lambda function as below:



      Stats1=lambda X,T:[[np.mean(x),np.std(x,ddof=1),len(x)] for x in [X[T=='Female'],[X[T=='Male']]]]
      Stats2=lambda X,Y:[[np.mean(x),np.std(x,ddof=1),len(x)] for x in [X[Y==9],[X[Y==8]]]]


      Stats1 works fine:



      [[muF,sigmaF,NF],[muM,sigmaM,NM]]=Stats1(X,T)


      But Stats2 gives error:



      [[muP,sigmaP,NP],[muN,sigmaN,NN]]=Stats2(X,Y)

      ---------------------------------------------------------------------------
      IndexError Traceback (most recent call last)
      <ipython-input-20-3678a0bdbb43> in <module>()
      ----> 1 [[muP,sigmaP,NP],[muN,sigmaN,NN]]=Stats2(X,Y)

      <ipython-input-18-940d7bad1eef> in <lambda>(X, Y)
      ----> 1 Stats2=lambda X,Y:[[np.mean(x),np.std(x,ddof=1),len(x)] for x in [X[Y==9],[X[Y==8]]]]

      IndexError: boolean index did not match indexed array along dimension 1; dimension is 2 but corresponding boolean dimension is 1


      Can anyone help me understand why and how to fix it.







      index-error






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 8 at 20:14









      SkatSkat

      32




      32






















          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55070397%2findexerror-boolean-index-did-not-match-indexed-array-along-dimension-1-dimensi%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55070397%2findexerror-boolean-index-did-not-match-indexed-array-along-dimension-1-dimensi%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          1928 у кіно

          Захаров Федір Захарович

          Ель Греко