Category "python"

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

How to write random matrix using loops and without numpy

How can I create two matrixes without numpy as A and B(can also do these operations)? import numpy as np A = np.random.randint(-9, 9, size=(5, 5)) B = np.rando

Firebase SDK for Python: How to initialize App using apiKey?

There is the following code inside a Node.js project: Soon.app = initializeApp({ apiKey: "AIzaSyB4fcG8rtNWAiAtSmxmK3q3JLfMvtNCGP4", projectId: "soonaverse"

Best way to complete asyncio gather if one task is complete

I have the following code where function_1 and function_2 runs independently. However, I want the script to complete once function_2 is complete. import asyncio

Binance API: OSError('Tunnel connection failed: 405 Method Not Allowed')

I am trying to access Binance Vanilla Futures data by using [this code][1] as a framework to better understand how to get the data. However, when I input my API

How to fix 'except ValueError' for python?

I am just starting to learn python and getting an error message that the syntax for calling calculator is wrong. Does anyone have any suggestions? My code: impo

Import geoviews in Anaconda

I am trying to install the geoviews module. I installed it successfully but when I am trying to import it in my code I have this message: No module named 'chann

Reshaping numpy array without changing the data

I'm trying to reshape an array of bitmap images that has a shape of (50,50,90000). How can I modify it so that I can get an array of (90000,50,50)? - I tried ar

Convert a a dictionary into an array in one line

I'm trying to simplify this: urls = [] soup = BeautifulSoup(r.text, "html.parser") items = soup.select('.mydiv a') for item in items: url = item['href']

how to split up a pandas series off of every two words in python

if I have a pandas dataframe with a description of an issue, how can I split each value into two separate words at a time? e.g Subject Number Issue 30493 "This

How to extract multiple texts from span elements using python selenium?

I am trying to extract all the texts in span into list, using the following HTML code from Selenium webdriver method: ['1a', '1b', '1c', '2a', ' ', ' ', '3a', '