Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 while creating a array using numpy.arrange, how to negate only the last 50 numbers?
#1
I'm creating an array using numpy and trying to negate the numbers from 50 to 100 in seperate steps as below..
\\


arr = np.arange(100)
arr1 = arr[50:100]*-1
arr2=(arr[0:50])
result=np.concatenate([arr2,arr1])
Is it possible to negate the intended numbers in the first step itself?
Quote
#2
The resulting array includes a gap. np.arange can not produce arrays with gaps.

arr = np.arange(100)
arr[50:] *= -1
np.r_[np.arange(50), np.arange(-50, -99, -1)]
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  import numpy in sub-files paul18fr 1 110 Aug-06-2019, 12:38 PM
Last Post: chakrimakam
  Converting set of tuples to set of 2D numpy arrays ThemePark 0 89 Aug-04-2019, 05:07 PM
Last Post: ThemePark
  Trying to replace for loops with numpy vspoloni 8 404 Aug-04-2019, 07:09 AM
Last Post: paul18fr
  Add column to numpy matrix Gigux 1 129 Aug-02-2019, 12:05 AM
Last Post: scidam
  Python/C API Matrix to Numpy jibarra 0 95 Jul-29-2019, 03:25 PM
Last Post: jibarra
  numpy.copy / numpy.delete paul18fr 3 149 Jul-26-2019, 01:51 PM
Last Post: paul18fr
  Error installing numpy srm 3 323 Jul-08-2019, 06:26 PM
Last Post: srm
  [pandas] How to re-arrange DataFrame columns SriMekala 8 698 Jun-22-2019, 12:55 AM
Last Post: scidam
  AttributeError: module 'numpy' has no attribute 'array aapurdel 7 1,436 May-29-2019, 02:48 AM
Last Post: heiner55
  Array in numpy Truman 5 3,589 May-26-2019, 10:14 AM
Last Post: snippsat

Forum Jump:


Users browsing this thread: 1 Guest(s)