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
  Replacing sub array in Numpy array ThemePark 4 176 9 hours ago
Last Post: scidam
  How to prepare a NumPy array which include float type array elements subhash 0 160 Mar-02-2020, 06:46 AM
Last Post: subhash
  numpy.where array search for string in just one coordinate adetheheat 1 283 Jan-09-2020, 07:09 PM
Last Post: paul18fr
  memory issue loading movie to numpy array djf123 1 203 Nov-07-2019, 06:19 AM
Last Post: ThomasL
  Numpy structured array Nitram 3 448 Sep-17-2019, 10:09 PM
Last Post: jefsummers
  numpy.copy / numpy.delete paul18fr 3 500 Jul-26-2019, 01:51 PM
Last Post: paul18fr
  [pandas] How to re-arrange DataFrame columns SriMekala 8 1,302 Jun-22-2019, 12:55 AM
Last Post: scidam
  AttributeError: module 'numpy' has no attribute 'array aapurdel 7 9,853 May-29-2019, 02:48 AM
Last Post: heiner55
  Array in numpy Truman 5 4,594 May-26-2019, 10:14 AM
Last Post: snippsat
  [split] Array in numpy aapurdel 1 421 May-25-2019, 08:05 PM
Last Post: buran

Forum Jump:


Users browsing this thread: 1 Guest(s)