I have a list of objects and I want to create another list of items but grouped by “Name” and two fields which are number of instances of a particular instance type. I have this : I am trying to get a count of the number of different “Type” columns whilst discarding any other column &#…
Fastest way to get values from dictionary to another dictionary in python without using if?
I need to find a way to get values from one dictionary to another, bases on key name match without using two loops if statement. Main goal is to make it run more efficiently since it’s a part of a larger code and run on multiple threads. If you can keep the dictionary structure it would help The second
match dtypes of one df to another with different number of columns
I have a dataframe that has 3 columns and looks like this: The other dataframe looks like this: I need to match the data types of one df to another. Because I have one additional column in df_1 I got an error. My code looks like this: I got an error: KeyError: ‘profitable’ What would be a workarou…
How to train a Keras autoencoder with custom dataset?
I am reading this tutorial in order to create my own autoencoder based on Keras. I followed the tutorial step by step, the only difference is that I want to train the model using my own images data set. So I changed/added the following code: My images are normal .jpg files in RGB format. However, as soon as t…
Searching the student-t distribution table for values using python
I would like to define a function that, given a student t distribution table, degrees of freedom(N-1) and P would interpolate over the values of the table to get the desired value of tv,p. Test the code for df=14 and t93. I would like to find another function, given a a student t distribution table, degrees o…
How do I make a program keep repeating until I input a specific data that stops it?
I’m trying to make a program in python so that when I input a number from 1 to 10, a specific set of program goes on and asks for another number from 1 to 10 and runs another program, until I enter 0(zero) and the program stops. So my guess was using a while loop but it didn’t quite work
Create multiple new rows per row in data frame
I have the following df: What I want to do know is add x new rows per row based on the id. So more specific spoken, I want to add a new column containing the date from a range of 7 days and then add a new row with the date for every ID in the df. so the output
Is there a way to make this “for loop” cleaner in Python?
I created a simple script that goes to a notepad file, reads it line by line and if it finds certain words it adds to a counter. Then at the end it spits out the final count for each word. The current implementation works, I just know it’s not the most efficient way of doing things. I would love for
remove empty dataframe from list and drop corresponding name in second list
I have two lists, where the first one is a list of strings called names and has been generated by using the name of the corresponding csv files. I have loaded the csv files into individual pandas dataframes and then done some preprocessing which leaves me with a list of lists, where each element is the data o…
Perform an exception for a list of funtions
hello people (I am new to python) Question: i use ipywidgets with buttons, i want to call a list of function, sometimes there’s a problem in a function (syntax, division by zero,…), i try to put an exception to pass the error and lunch the next function, don’t work :( I’m running in ju…