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
  [pandas] How to re-arrange DataFrame columns SriMekala 8 254 Jun-22-2019, 12:55 AM
Last Post: scidam
  AttributeError: module 'numpy' has no attribute 'array aapurdel 7 618 May-29-2019, 02:48 AM
Last Post: heiner55
  Array in numpy Truman 5 3,009 May-26-2019, 10:14 AM
Last Post: snippsat
  [split] Array in numpy aapurdel 1 103 May-25-2019, 08:05 PM
Last Post: buran
  [numpy]add a value to an array elmismo999 1 141 May-23-2019, 04:15 PM
Last Post: michalmonday
  "erlarge" a numpy-matrix to numpy-array PhysChem 2 191 Apr-09-2019, 04:54 PM
Last Post: PhysChem
  How to arrange the four pictures of a matplotlib.pyplot? vokoyo 0 227 Apr-04-2019, 10:58 PM
Last Post: vokoyo
  counting the occurence of a specified number in a numpy-matrix PhysChem 1 175 Apr-03-2019, 01:37 PM
Last Post: PhysChem
  How to get the size of a numpy array? mcgrim 2 240 Mar-23-2019, 02:25 PM
Last Post: perfringo
  How convert multidimensional array to two dimensional array tkkhan44 1 275 Feb-20-2019, 05:00 AM
Last Post: scidam

Forum Jump:


Users browsing this thread: 1 Guest(s)