Skip to content
Advertisement

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

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

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

Advertisement