Python Forum
change array elements dependent on index
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
change array elements dependent on index
#1
Greetings,

is there an easier way to write the following with some kind of slicing arithmetics?

for k in range(1, N-1):
    A[k] = some_function(k) * some_array[k]
where A and some_array are numpy arrays and some_function returns a double.


Best,

SL
Reply


Messages In This Thread
change array elements dependent on index - by SchroedingersLion - Nov-21-2019, 09:52 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to remove some elements from an array in python? gohanhango 9 1,139 Nov-28-2023, 08:35 AM
Last Post: Gribouillis
  Modify an Energy Model to account for year dependent interest rate rather than only t giovanniandrean 0 425 Oct-10-2023, 07:00 AM
Last Post: giovanniandrean
  Change a numpy array to a dataframe Led_Zeppelin 3 1,106 Jan-26-2023, 09:01 PM
Last Post: deanhystad
  How to change the datatype of list elements? mHosseinDS86 9 1,955 Aug-24-2022, 05:26 PM
Last Post: deanhystad
  array change svm 6 1,477 Jun-23-2022, 01:01 PM
Last Post: svm
  ValueError: Length mismatch: Expected axis has 8 elements, new values have 1 elements ilknurg 1 5,114 May-17-2022, 11:38 AM
Last Post: Larz60+
  Replace elements of array with elements from another array based on a third array Cola_Reb 6 1,834 May-13-2022, 06:06 PM
Last Post: deanhystad
Question Change elements of array based on position of input data Cola_Reb 6 2,112 May-13-2022, 12:57 PM
Last Post: Cola_Reb
  All Array Index JohnnyCoffee 3 2,585 Feb-26-2021, 06:46 AM
Last Post: ndc85430
  Sorting Elements via parameters pointing to those elements. rpalmer 3 2,585 Feb-10-2021, 04:53 PM
Last Post: rpalmer

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020