Python Forum
change for loop into numpy functions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
change for loop into numpy functions
#2
It's look like results coming from FEM Smile

My comments:
  • "append" is your enemy (dynamic allocation memory = time consuming)
  • "numpy.unique" provides you a new matrix without double node values ⇒ then "numpy.size" gives you the number of rows of your new matrix ⇒ use "numpy.zeros" to reserve in memory the matrix (gain of time)
  • sorting nodes numbers is a good idea: the second node follows immediatly the first one ⇒ you would be able to sum "i" index with "i+1" one (so I think vectorization use is possible)

I do not use Pandas, but frames seem to be no more no less that disctionnaries (Keys + values), so it is easy to extract it and to work with, isn't it?
Reply


Messages In This Thread
change for loop into numpy functions - by ToffiFaye - Feb-05-2021, 10:26 PM
RE: change for loop into numpy functions - by paul18fr - Feb-06-2021, 11:38 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Numpy] How to store different data type in one numpy array? water 7 912 Mar-26-2024, 02:18 PM
Last Post: snippsat
  Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" kalle 2 2,785 Jul-19-2022, 06:31 AM
Last Post: paul18fr
  Change classic loop to TensorFlow tf.while_loop vsl_neuro 0 1,815 Dec-15-2020, 07:57 AM
Last Post: vsl_neuro
  "erlarge" a numpy-matrix to numpy-array PhysChem 2 3,097 Apr-09-2019, 04:54 PM
Last Post: PhysChem
  Convert indexing For Loop from MATLAB (uses numpy and pandas) bentaz 3 4,272 Mar-20-2018, 08:29 PM
Last Post: bentaz

Forum Jump:

User Panel Messages

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