Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. Independent Developers
  4. combining two different NumPy arrays
Forum Updated to NodeBB v4.3 + New Features

combining two different NumPy arrays

Scheduled Pinned Locked Moved Solved Independent Developers
dataarray
2 Posts 2 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Sachin BhattS Offline
    Sachin BhattS Offline
    Sachin Bhatt
    wrote on last edited by
    #1

    hey everyone
    first here is the code:

    
    In [1]:
    np.array([True, 1, 2]) + np.array([3, 4, False])
    Out[1]:
    array([4, 5, 2])
    

    I'm taking the Data Science course on scaler. One of the examples lacked an explanation of the numpy addition rules. I've attached a photo of the example as well as the query. What I didn't get was how two arrays with different values could be added together to produce such a result.

    jsulmJ 1 Reply Last reply
    0
    • Sachin BhattS Sachin Bhatt

      hey everyone
      first here is the code:

      
      In [1]:
      np.array([True, 1, 2]) + np.array([3, 4, False])
      Out[1]:
      array([4, 5, 2])
      

      I'm taking the Data Science course on scaler. One of the examples lacked an explanation of the numpy addition rules. I've attached a photo of the example as well as the query. What I didn't get was how two arrays with different values could be added together to produce such a result.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @Sachin-Bhatt My explanation: True evaluates to 1 in a numerical context. False evaluates to 0. So:

      True +3 = 4
      1 + 4 = 5
      2 + False = 2
      

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      4
      • Sachin BhattS Sachin Bhatt has marked this topic as solved on

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved