I have two scripts 1 and 2, I would need these two script to work independently from one another, but I also need script 2 to be able to use the function in script 1 if needed. I tried to automate as much as possible, so each script has a number of variables inside already defined. Here is an oversimplified
Tag: python
pip ignores python_requires field in setup
I have the following in my setup.cfg file: Problem is that I created an enviroment with Python 3.7 and installation had no problems. Installation command: Shouldn’t pip require a Python 3.8 enviroment? Here is the test.PyPI link: PyPI project, and here the repo: GitHub repo I know that the setup.cfg fil…
RPi tcp video streaming with opencv and gstreamer using v4l2h264enc
I am trying to stream frames using OpenCV and Gstreamer in Python. I’m on a 64 bit Bulseye Raspberry Pi 4. This is the pipeline I am using on the Raspberry: It seems to be some problem with v4l2h264enc. Enabling GST_DEBUG=4 gives me These two errors look most important to me, but you can see the full lo…
Executing functions through dictionaries
My script executes depending on user’s input, like this: The problem is that I can have over 15 different choices, so I would like to make it cleaner using dicts, but I can’t get it to work. This is what I did. In the class init for sh: And so on. Further down in the class: And finally the input
How to write a polynomial in x**3 instead of x using Polynomial
At the moment i have a polynomial (of a galois field) in function of x. But i want to “evaluate” it in x^3. Any ideas on how to do it? So now f is in function of x: f(x) But i want to have f(x^3) Answer I am the author of the galois library. Converting f(x) to g(x) = f(x^3)
How to add elements of a 1D NumPy array to NumPy subarrays with the same index?
Let’s say I have a NumPy array a with shape (3, 5, 7) and a 1D NumPy array l with shape (3, 1). I want to add the 0th element of l to the 0th subarray in a, the 1st element of l to the 1st subarray of a, and the 2nd element of l to the 2nd and last
Convert JSON Dict to Pandas Dataframe
I have what appears to be a very simple JSON dict I need to convert into a Pandas dataframe. The dict is being pulled in for me as a string which I have little control over. I have tried the usual methods such as pd.read_json() and json_normalize() etc but can’t seem to get it anywhere close. Has anyone…
I suddenly receive no stream data from Twitter stream (requests.get(…2/tweets/search/stream))
I’m working on a screenshot bot for Twitter using Python. My app collects tweet from a filtered stream and replies with an image of the tweet. Yesterday, my bot worked well: connected to stream, and made replies. Today, it still connects to stream but returns nothing. Here is the code: I’ve search…
How to replace df.loc with df.reindex without KeyError
I have a huge dataframe which I get from a .csv file. After defining the columns I only want to use the one I need. I used Python 3.8.1 version and it worked great, although raising the “FutureWarning: Passing list-likes to .loc or [] with any missing label will raise KeyError in the future, you can use…
Iterating over nested dictionary returns only first element
I have this nested dictionary (“dictionary of dictionaries”) And I want to create a new one which would consist of outer keys associated with inner values (see expected output below) I use this recursive function: But when I try to print that: I get this (only the first dictionary is processed: Bu…