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
  Creating look up table/matrix from 3d data array chai0404 3 329 Apr-09-2020, 04:53 AM
Last Post: buran
  converting dataframe to int numpy array glennford49 1 305 Apr-04-2020, 06:15 AM
Last Post: snippsat
  Replacing sub array in Numpy array ThemePark 5 391 Apr-01-2020, 01:16 PM
Last Post: ThemePark
  How to prepare a NumPy array which include float type array elements subhash 0 264 Mar-02-2020, 06:46 AM
Last Post: subhash
  numpy.where array search for string in just one coordinate adetheheat 1 404 Jan-09-2020, 07:09 PM
Last Post: paul18fr
  memory issue loading movie to numpy array djf123 1 330 Nov-07-2019, 06:19 AM
Last Post: ThomasL
  Numpy structured array Nitram 3 632 Sep-17-2019, 10:09 PM
Last Post: jefsummers
  numpy.copy / numpy.delete paul18fr 3 692 Jul-26-2019, 01:51 PM
Last Post: paul18fr
  [pandas] How to re-arrange DataFrame columns SriMekala 8 1,540 Jun-22-2019, 12:55 AM
Last Post: scidam
  AttributeError: module 'numpy' has no attribute 'array aapurdel 7 13,624 May-29-2019, 02:48 AM
Last Post: heiner55

Forum Jump:


Users browsing this thread: 1 Guest(s)