I have a small list: and I have a matrix too. for example: And I need to determine if any of the elements of l ist2 of this array are not in the matrix2. I try to use np.isin() : But this code only shows if there is the elements in the matrix or not completely. But I need this
Tag: numpy
Change x-axis scale size in a bar graph
For some set of data, here is my code which generates a bar graph like this: The values on the x-axis ranges from 1975 to 2017. And the values on the y-axis are some decimal values. In the x-axis of the plot, the values are overlapping. I want to change the scale as 1975, 1980, 1985 so on to keep
numpy.AxisError: axis 2 is out of bounds for array of dimension 0
I’m creating a program the requires a black and white image and two arrays containing the X and Y coordinates of both black and white pixels respectively. I have a program that utilizes OpenCV and binary thresholding to create a black and white image (code source). Hear is the code I have in full so far. The problem I have
Filter and calculate % of a dataframe column
I am trying to calculate the % of men and women in a dataframe column named “gender”. “gender” is defined as an object taking 3 values : “Man” “Woman” “nan” (NA). I did this : But it returns 0.0% for both. When i check ‘total’ value it returns : 10123033 but zero for both ‘men’ and ‘women’ Thanks. Answer pay
Plot a triangle contour/surface matplotlib python: tricontourf/meshgrid
Given the following image, where plt.Polygon was used to create the triangle and plt.contourf the contour, i would like to ‘cut’ off the regions marked in X so that i only get the contour inside the triangle. How would i do this? I’ve tried placing NaN values in the mentioned regions but the edges are square and therefore requires a
Finding areas of non-overlapping edges of two distributions
I am trying to find a way to calculate the overlapping (intersection) and non-overlapping areas of two distributions. Based on some posts (like this: FINDING AREA) I could figure out how to calculate the intersection of the two plots. But I had no luck finding the non-overlapping part. Given this example distributions: I wonder how I can calculate the areas
Calculate distance between points in polygon
I found a lot of posts on how to calculate distance between two points or from one point to polygon but I simply can’t find how to calculate distance of each edge. I have a polygon, where the coordinates are these: I simply want to calculate length of each edge. Maybe I should use (math.dist(p, q)) with for loop or
Fast pathfinding and distance matrix in 2d grid
Context: I’m working on a warehouse simulation that supports different floor designs and simulates one or multiple agents that are tasked with order picking. One order can consist of more than one product. The routing for picking products is solved as a capacitated vehicle routing problem (CVRP). This requires a distance matrix between product locations, for which the A* algorithm
Remove leading zeroes pandas
For example I have such a data frame And I need to remove all leading zeroes and replace NONEs with zeros: I did it with cycles but for large frames it works not fast enough. I’d like to rewrite it using vectores Answer you can try str.replace
tf.data: create a Dataset from a list of Numpy arrays of different shape
I have a list of Numpy arrays of different shape. I need to create a Dataset, so that each time an element is requested I get a tensor with the shape and values of the given Numpy array. How can I achieve this? This is NOT working: since you get, as expected: Can’t convert non-rectangular Python sequence to Tensor. p.s.