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 844 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.
  • S Offline
    S Offline
    Sachin Bhatt
    wrote on 20 Feb 2023, 21:19 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.

    J 1 Reply Last reply 21 Feb 2023, 06:34
    0
    • S Sachin Bhatt
      20 Feb 2023, 21:19

      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.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 21 Feb 2023, 06:34 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
      • S Sachin Bhatt has marked this topic as solved on 16 Apr 2023, 21:00

      1/2

      20 Feb 2023, 21:19

      • Login

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