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
  memory issue loading movie to numpy array djf123 1 51 Nov-07-2019, 06:19 AM
Last Post: ThomasL
  Numpy structured array Nitram 3 225 Sep-17-2019, 10:09 PM
Last Post: jefsummers
  numpy.copy / numpy.delete paul18fr 3 273 Jul-26-2019, 01:51 PM
Last Post: paul18fr
  [pandas] How to re-arrange DataFrame columns SriMekala 8 941 Jun-22-2019, 12:55 AM
Last Post: scidam
  AttributeError: module 'numpy' has no attribute 'array aapurdel 7 4,284 May-29-2019, 02:48 AM
Last Post: heiner55
  Array in numpy Truman 5 4,131 May-26-2019, 10:14 AM
Last Post: snippsat
  [split] Array in numpy aapurdel 1 284 May-25-2019, 08:05 PM
Last Post: buran
  [numpy]add a value to an array elmismo999 1 370 May-23-2019, 04:15 PM
Last Post: michalmonday
  "erlarge" a numpy-matrix to numpy-array PhysChem 2 410 Apr-09-2019, 04:54 PM
Last Post: PhysChem
  How to arrange the four pictures of a matplotlib.pyplot? vokoyo 0 458 Apr-04-2019, 10:58 PM
Last Post: vokoyo

Forum Jump:


Users browsing this thread: 1 Guest(s)