Skip to content

Tag: matrix

Create a matrix with np.random.normal

I need to create an nxn matrix in which the numbers in the cells are distributed following a Gaussian distribution. This code may not go well because it fills a cell with a sequence. how can I do? Answer Edited for border of zeros np.random.normal takes a size keyword argument. You can use it like […]

Pandas division method

I am trying to divide two series of different length to return the matrix product dataframe of them. I can multiply them using the dot method (from this answer): I’ve tried the div method, but this just fills the dataframe with NaNs: Likewise the standard division operator also returns the same result: So I’m a bit stumped as to what

How can I find the dimensions of a matrix in Python?

How can I find the dimensions of a matrix in Python. Len(A) returns only one variable. Edit: Is (I assume) generating a matrix of integers (less likely strings). I need to find the size of that matrix, so I can run some tests without having to iterate through all of the elements. As far as the data type goes, I

Pretty print 2D Python list

Is there a simple, built-in way to print a 2D Python list as a 2D matrix? So this: [[“A”, “B”], [“C”, “D”]] would become something like A B C D I found the pprint module, but it doesn’t …