EDIT: I have changed np.array to np.arange to better explain what my problem is.
Being new to Python, I still struggle a lot with data structures. This seems like it should be a very obvious (and obviously duplicate) question, yet I can't understand enough of other explanations to make it work.
I need to create a list of lists (and / or arrays, I'll explain this in a minute), all with different lengths and ranges. I set up my initial arrays in the following way, but I still don't understand how to create the 'partotal' array. I know the syntax is wrong but still don't understand why.
import numpy as np
par1 = np.arange([10,80,1])
par2 = np.arange([50,120,1])
par3 = np.arange([0,40,1])
par4 = np.arange([0,30,1])
partotal = np.array([par1][par2][par3][par4])
The second problem, as you may have guessed, is that I have no idea whether I should be using numpy arrays, list of lists, pandas, or something else entirely. Since all my arrays are of different lengths, I find it hard to understand how to put things together or remove them again.
EDIT: The purpose of partotal is to create a set of starting positions for another function (see below)
inputnumber = 200
def positions(partotal, inputnumber):
return np.random.uniform(partotal, size=(inputnumber, len(partotal)))
I know this must sound very basic but as a beginner I find it confusing and difficult. Most answers focus on syntax and don't help develop true insight. If someone can take some time to explain the very obvious I would appreciate it.
FINAL EDIT: The answer was very simple when I understood my own problem. I won't delete the rest of the post, for the sake of others who might need to follow my thought process.
par = 3
par1 = np.random.uniform(10,80,size=par)
par2 = np.random.uniform(5,120,size=par)
par3 = np.random.uniform(0,40,size=par)
allpar = np.array([par1,par2,par3])
partotalfor, it's very hard to suggest how to build it. Are you looking for a 4x3 array? An array of 4 lists? Or an array of arrays? Something different? You can build a 4x3 array out of eithernp.array([par1, par2, par3, par4])or by juststacking the arrays together, but I don't know if that's what you're looking for.par1throughpar4all have the same length, which is 3. Were you expectingnp.array([10,80,1])to work likerangeorarange, and produce a 70-element result?arangeorlinspace(which is best?) that would give me a bunch of lists, right? So then how do I create a list of lists for them?