Category "python"

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

I want to get a way to highlight code using the python Tkinter Text control

I want to implement a code highlighting function, but I don't know how to use this tk.Text 。 (not necessarily python, of course) I hope to get a highligh

Multiple int input in same line python [duplicate]

I want to take multiple integer inputs in the same line. I know I can take str input and then convert them into integer in the next line but i

C-API register a ufunc loop against builtin ufunc

I am looking to build a numpy extension module which declares a new structured dtype and provides the necessary inner ufunc loops to allow built-in math operati

Share Y axis in Matplotlib with different ticks and labels

I want to plot 2 adjacent figures sharing the y axis but I want to specify different ticks and labels to the left of the left figure and to the right of the rig

How to pass a trained model to KerasClassifier?

I have a dozen pre-trained DNNs that I wish to add to a sklearn ensemble. The issue is that it seems I can not provide pre-trained models to KerasClassifier. cl

Finding the shortest path to solve colored water sorting games

So my aunt plays this now popular mobile game, shown in the picture below. She got stuck on a certain level and asked me if I can solve it. Knowing that I'm not

Drop rows of dataframe if the rows have continuously the same value

I am dealing with metered time series data, that should not have the exact same value for more than n steps. I want to build a script that, given a threshold n,