Recreate colormap based on colorscale in matplotlib

I have an image of a color scale I filter out the actual color scale by using import cv2 import numpy as np colorbar = cv2.imread(‘colorbar-scheme-elevation.png’, cv2.IMREAD_UNCHANGED) colorbar = cv2.cvtColor(colorbar, cv2.COLOR_BGRA2BGR) hsv = cv2.cvtColor(colorbar, cv2.COLOR_RGB2HSV) lower_gray = np.array([0, 0, 0]) upper_gray = np.array([255, 10, 255]) mask = cv2.inRange(hsv, lower_gray, upper_gray) mask = cv2.bitwise_not(mask) res =… Read More Recreate colormap based on colorscale in matplotlib

Migrating from Python 2.7 to 3.7 – difference between isinstance(obj, None) vs is None

I have to migrate a project from Python 2.7 to 3.7. This line of code used to work in 2.7 if isinstance(obj, None): for some reason it doesn’t anymore. If I modify it this way: if isinstance(obj, type(None)): it will work though. But my question is, what is the difference between this call: isinstance(obj, None)… Read More Migrating from Python 2.7 to 3.7 – difference between isinstance(obj, None) vs is None

How to prevent: "UserWarning: Boolean Series key will be reindexed to match DataFrame index"

I am having some issues with my Python code. When working with DataFrames I get a UserWarning and I’m not really sure of how to prevent it. for index in matplatsID: mask = (kameraData["Tid"].dt.hour >= timme) & (kameraData["Tid"].dt.hour < timme+1) matplatsSummaHastigheter += kameraData[mask][kameraData["MätplatsID"] == index]["Hastighet"].sum() matplatsAntalFordon += kameraData[mask][kameraData["MätplatsID"] == index]["Hastighet"].count() UserWarning: Boolean Series key will… Read More How to prevent: "UserWarning: Boolean Series key will be reindexed to match DataFrame index"