Category "python"

how to change label text in Tkinter with callback function out of window.mainloop

im triggering callback function witch reads encoder output with GPIO.add_event_detect so the global counter has current value, but i cant pass it to tkinter lik

How to conditionally assign values from another dataframe?

I want to merge 2 dataframes without using the function '.merge' and I try to assign a value to a dataframe column based on an interval and an id. intervals = p

Converting dictionary to dataframe

In the following code, I have defined a dictionary and then converted it to a dataframe my_dict = { 'A' : [1,2], 'B' : [4,5,6] } df = pd.DataFrame() df = df.app

Python + Flask + Discord: How to send a message through discord through a flask endpoint?

I'm trying to send a message with discord, activated through a Flask endpoint I get the following error message when I call http://127.0.0.1:5000/send RuntimeEr

How can I store two values for one key with Replit Database

I'm using CoingGecko API for acquiring info about crypto. I have a function for getting a json from the API of crypto currencies. Then I upload the id of crypto

How to create a labelled QProgressBar in PySide?

This is exactly what I am trying to re-create I've tried a 4x4 grid layout with QLabels underneath a QProgressBar but it looks awful and I am wondering if ther

How to collapse the code section in Google Colab Notebook but keeping the results shown?

As you can read on the title, I'm currently trying to make the code section collapsing without collapsing also the results section. For example without the coll

ValueError: num must be 1 <= num <= 5, not 0 error

I am stuck with this code written in py2 on psychopy. I am not an expert with coding. I am trying to run the function "analyzeStaircases(stairs, stairInfo['Aver

Handwritten digit recognition without deep learning techniques

I have a project to hand in which requires me to develop a program in python which would recognise handwritten numbers given in the form of image(i imagine the

What is a rank 1 array in Numpy

Consider the following vector: import numpy as np u = np.random.randn(5) print(u) [-0.30153275 -1.48236907 -1.09808763 -0.10543421 -1.49627068] When we print

Create a dictionary where the keys are values of dictionaries inside lists in a dictionary and the values are the number of times they appear

I have this dictionary of lists of dictionaries (I cannot change the structure for the work): dict_countries = {'gb': [{'datetime': '1955-10-10 17:00:00', 'city

Unexpected Output error in array analyzer program

Currently I am trying to solve the following problem: Ratiorg got statues of different sizes as a present from CodeMaster for his birthday, each statue having a

plotting with subplots in a loop

z = {'A': [0.3618426, 0.36146951], 'B': [1.8908799, 1.904695], 'C': [2.1813462e+08, 2.1833622e+08], 'D': [0.89925492, 0.89953589], 'E': [2.6356747, 2.6317911],

Python/Docker - Unknown server host 'db' when migrating

I am trying to migrate a program using python manage.py db migrate in my Visual Studio terminal but when I run it I am getting an error named (2005, "Unknown se

Pyspark: join and union in for loop

I have a really simple logic that I would like to understand how I can make it work in pyspark. for data in df1: spark_data_row = spark.createDataFrame(data

Creating a regression summary table with multiple regressions, adding 1 independent variable at a time (R/Python)

I would like to know, whether there is a pre-built function / package which does a simply OLS regression, by adding one independent variable from a pre-defined

Why do my files in vscode keep being deleted after trying to execute them?

I am currently learning to code with python in vscode but recently I have been having problems with file seemingly deleting themselves after attempted execution

Python scikit learn pipelines (no transformation on features)

I am running different machine learning models on my data set. I am using sklearn pipelines to try different transforms on the numeric features to evaluate if o

How can I find the nearest date after another date in a different column in grouping by ID using R?

I am looking for a method that will look at each date in "Date A" and find the next nearest date after that value in "Date B" by ID (group_by). I then want to c

Single updates using tf.GradientTape with multiple outputs

I defined the following model, which has two distinct outputs: input_layer = keras.layers.Input(shape = (1, 20), name = "input_features") # Shared layers hidde