I have tried doing this with dynamic-rest and couldn’t get it to work, now I am trying with the built in ordering method in django rest-framework, still can’t get it to work. I have a feeling it is the method I am using get get these results from the database, but I do not know of any other way, s…
Tag: python
Select all rows of a dataframe where exactly M columns in any order satisfy a condition based on N columns
I want to select all the rows of a dataset where exactly M columns satisfy a condition based on N columns (where N >= M). Consider the following dataset The code below selects conditions where at least one (or more) of the columns (y0, y1, y2, y3) are True. However, I want to select rows where exactly 2 (a…
Matching plot line colour with the name of the division
I have been trying to plot mean of ‘Sales’ for 7 divisions (blue, green, grey, orange, purple, red, yellow) for each response month. Here is a code snippet: graph image How can I ensure that colour of plot line for each division matches the name of the division i.e. ‘blue’ colour plotl…
Check substring with 1 character difference in python
I have list of thousand of strings sub_strings, and list of millions of strings strings I want to check if strings[i] have substring from sub_strings or substring that’s different in 1 character expected Answer Here’s a route for solving: That will spit out [True, True, True, True, False, True] Bu…
Sending a message 2 hours after the last message discord py
So, I can’t figure out how to make my discord bot send a message 2 hours after the last message. The problem for me is that I want the bot to reset the 2 hours timer if a new message comes, but I don’t know how to do that without breaking the program. Can anyone help me out? Answer To
Converting dataframe to dictionary with country by continent
I have a .csv and dataframe which has 2 columns (country, continent). I want to create a dictionary, carrying the continent as key and a list of all countries as values. The .csv has the following format: country continent Algeria Africa Angola Africa and so on. I tried using: But this gave me the following o…
While Loop break stops my statement from Printing
(Python/PythonAnywhere) My Code Now: This is what goes after: (The code didn’t wanna include this) The problem, (from what i can understand) is that the break messes with the print, “I’m Sorry” and when the loop is broken, it also stops the print from printing, moving on to asking the …
Elimination of outliers with z-score method in Python
I am cleaning a dataset using the z-score with a threshold >3. Below is the code that I am using. As you can, I first calculate the mean and std. After the code goes in a loop and checks for every value the z-score and if it is greater than 3 and, if yes, the value is treated as an
Save keras preprocessing layer
I have a model where I’m doing different preprocessing, outside the model itself. One part of the preprocessing is using a category encoder based on keras with: I apply this than with to my pandas dataframe. Now I want to store my model and in order to store the model I also have to store the 2 preproce…
Does my learning curves show overfitting? [closed]
Closed. This question is not about programming or software development. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on anoth…