I have a dataframe called “nums” and am trying to find the value of the column “angle” by specifying the values of other columns like this: When I do so, I do not get a singular number and cannot do calculations on them. What am I doing wrong? nums Answer First of all, in general you s…
Tag: python
how to turn dictionary of integers into a heat map using matplotlib
I am wondering how I can make a heatmap using matplotlib. I cant really explain it so ill just show you an example. here is an example grid it is stored in a dictionary like this I was wondering how I can convert this dictionary into a heat map using matplotlib. Answer Here’s a very barebones example: N…
How to specify timeout on aws opensearch library for python
I am using https://opensearch.org/docs/latest/clients/python/ to interact with an opensearch instance but I need somehow to to extend the lifetime of the request easily. I searched the docs and I couldn’t find a timeout parameter. Is there a way to specify a timeout? Answer You can pass timeout=60 (or w…
Stream OpenCV Video Capture to flask server
Greeting, I was working on a drone project, I wanted to take stream from my drone process it on my laptop and give a command based on processing, I was using the flask framework from the same. Currently, as the first step I want to take the stream from drone and PUT it to the flask server and view it
How to use flake8 as unittest case?
I want to make flake8 a unittest case for all my source files. The unittest have to fail when the code is not PEP8 conform. I still do this with pycodestyle that way. But I don’t know how to do this with flake8 after import flake8. Answer As others have pointed out, this is not something you should be d…
kivy: Is it possible to have the same Tabbed Panel on different screens?
im wondering if it is possible to have a Tabbed Panel permanently even though im switching between screens? Ive tried having the TabbedPanel outside the mainscreen, on a different class and so on. So far when i switch to the FirstScreen the TabbedPanel disapears. Python: kv: Answer Rather than adding the Tabb…
Read the first two lines from a text file named “file1.txt” Write the two lines read from “file1.txt” to a new file “file2.txt”
I need to read the first two lines from a text file named “file1.txt” Write the two lines read from “file1.txt” to a new file called “file2.txt” Read “file2.txt” and Print the contents But this is not working and I can’t find the error. please help Answer
Convert Spreadsheet to Data Frame Syntax in Python
Out of the box (and broad) question here: I have a spreadsheet that I’d like to use as an example in a question to the SO community, but I have a feeling most SO helpers would not like to deal with spreadsheets as data input/examples. Instead, I’d like to provide an already-transformed data frame …
Python, crop an image to extract a single side of it
I have an image and the vertexs of each sides of it, meaning that, if we see each side as a segment (A,B) i have both the A and B point coordinates. Now i would like to crop the image so that i have only one segment of the image (which is the side), for example That’s just one side
Replacing a variable in a list with the result of a regex search in a Python function
I have three lists lst_a to lst_c. I would like to write a function that takes each item from the lists, performs a regex search according to lst_b with search group position according to lst_c and replaces the variables in lst_a with the search results. This is my code: Searching and finding works, but I can…