Category "python"

How to catch a FFMPEG exception with subprocess?

I'm doing some work on subtitles and some videos have 1 subtitle track, others have 2 subtitle tracks. For those that have 2, I use the 2nd one (index = 1). I'm

How to get the value of a python script I run through ssh

I am using 2 raspberry pi and each of them has a camera connected. I am trying to run, from the first pi, a script to get the video feed of the second one. And

Python 3 does not show the barchart

I am trying to make this bargraph appear in the python run screen. But for some reason, it does not show the graph on the screen. However, if I put this code on

Cannot get a file to be read into a list of stock tickers and then get yfinance data for each

I am trying to read a csv file into a dataframe and then iterate over each ticker to get some yahoo finance data, but I struggle with matching the right data ty

How to get colored legend with seaborn barplot

There is a problem with plt.legend in seaborn and matplotlib. What is wrong with it? I can't see the legend color. plt.figure(figsize=(30,10)) plt.xticks(rotati

Find differences between a set of csv files in folder 1 against a set of csv files in folder 2?

There are a number a files that need to be compared for differences in their rows; difference not as in subtraction but as in what values are different for each

How can you iterate through a tuple (str), then return a dictionary containing the keys (from the tuple) and the index of the keys as the values?

How can you iterate through a tuple (str), then return a dictionary containing the keys (from the tuple) and the index of the keys as the values? Input: tup = (

Am trying to launch in Cpanel, but am getting a Module not found error

enter image description hereI'm new to Cpanel and am trying to launch my python Django project, I think I've set up everything correctly but am getting this err

labelled image object doesn't exist

I get the pictures from the wikipedia in a class and add them to the dict, when I want to return it and add the result to the label image, I get an error import

SystemError with spidev after upgrade

I'm getting the following error: Traceback (most recent call last): File "/home/hydro1/hydroponic_newloop.py", line 6, in import spidev SystemError: Type does

google.cloud.firestore_v1.client.Client expires

Using google.cloud.firestore_v1.client.Client to work with firebase database when intertacting with it after a while of non interaction i get : google.api_core

Elbow Method for K-Means in python

I'm using K-Means algorithm (in sklearn) to cluster 1-D array of values, and I want to decide the optimal number of clusters (K) in my script. I'm familiar with

pycord RuntimeError while trying to start ipc Discord Bot

I'm following this tutorial to create a discord bot with a dashboard but when I run my bot.py file I'm getting an error. What am I doing wrong? bot.py: import d

Reduce Duplications in Github Actions

I have read and tested different things but didn't found a solution. Maybe I have to live with the boilerplate, but I am not yet done trying it. I have the foll

Calculating rolling XNPV in Python

I need to calculate XNPV of cash flows at different future dates. Is there any function to do this in numpy, pandas or plain python? Consider a dataframe like s

dateEntry to only extract the year from user input instead of daymonthyear? In Python

I am creating a GUI using tkinter in python and I want to print the date of what the user had selected using dateEntry. Here is what my code looks like: import

Altair: encoding field is specified without a type

Hi my gorgeous friend on the Internet, I have a question about how to plot a Chart in Altair. I have been struggling with this error since yesterday and still h

Unable to pip install pyodbc on mac

I am trying to install pyodbc with pip on macOS(12.3.1), but that didn't work. In error log, Message says "fatal error: 'sql.h' file not found". Some people are

How to return custom JSON response in DRF?

I have created API for News model: models.py class News(models.Model): title = models.CharField(max_length=255) created_at = models.DateTimeField(auto_n

Simulating a square wave with a duty cycle (python)

I was trying to simulate a square wave with a duty cycle but something went wrong and i've been spending the last 3 hours understandig why. Here are the picture