Skip to content
Advertisement

Tag: numpy

Reproducing a 2d histogram in Python

I’m working with a very large dataset in Python, so I’m trying to use histograms instead of arrays (the arrays get way too large for saving/loading/mapping). I’m crawling over a bunch of files and pulling information from them, and I would like to then take the information and remake the histograms afterwards. I can do this with a 1D histogram

Convert dictionary with coordinates and values to 2D array

Assume the next dictionary is given: In the dictionary above each key displays a point in the matrix (x, y) and a value displays the value found in the matrix. How could I construct an array that will contain the values located at each point x, y? According to the dictionary above the expected result is: Answer You could use

Python: get attribute from class objects stored in an array

I would like to get the attribute of every object contained in an ndarray. Consider the following code, where after vectorization the function returns an ndarray with the objects. From each of these objects in the array, I would like to get the attribute and store the attributes in a new array. The classes and functions are a dummy for

Getting same result for different CSV files

DESCRIPTION: I have a piece of Python code, and this code takes a CSV file as input and produces a .player file as output. I’ve four different CSV files, hence, after running the code four times (taking each CSV file one by one), I’ve four .player files. REPOSITORY: https://github.com/divkrsh/gridlab-d DATA: The data in the CSV files are put through this

How to find nearest point in segment in a 3d space

I am solving an algorithmic problem which sounds like this: Given a three-dimensional space and segments in it. Find the point with minimal distance to all of the segments. Example input: in the first line N – the number of segments, in the N next lines given the begin and the end of each segment: x1 y1 z1 x2 y2

More pythonic way of creating within-class scatter matrix

I am looking for a better way of calculating the following I would prefer getting rid of the for loops using numpy. This is the within-class scatter matrix for fischers linear discriminant. Answer You can write as follows: This is because sum_i x_i x’_i = X’ X, where X is (N, 3) matrix and x_i = X[i,:], i.e. i-th row

Advertisement