I am trying to calculate the sum of sales for stores in the same neighborhood based on their geographic coordinates. I have sample data: ID SALE X Y X_MIN Y_MIN X_MAX Y_MAX 1 100 23 44 22 43 24 45 2 120 22 45 21 44 23 46 3 110 21 41 20 40 22 42 4 95 24 46
Tag: if-statement
Python, comparing dataframe rows, adding new column – Truth Value Error?
I am quite new to Python, and somewhat stuck here. I just want to compare floats with a previous or forward row in a dataframe, and mark a new column accordingly. FWIW, I have 6000 rows to compare. I need to output a string or int as the result. My Python code: I get the error: ValueError: The truth value
How to obtain the values of provided data in which a minimum value occurs in a list?
So I’ve been trying to select 2 parameters as a result in which the minimum value occurs in another calculation (the error below). Consider the following dummy code for better understanding: When calling the function defined min_error(par1, par2); par1 and par2 are lists so my nested for loop is going to append multiple values in the output dictionary. At this
Splitting list in two new lists python [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 months ago. Improve this question in Python I have a list with 96 entries, some are positiv, some are negative. I now want to new lists with 96 entries each.
If-Elif Statement is not working as I expected in python [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 months ago. Improve this question I want to adjust lists to the same length but the if-elif statement is not working as I thought, its very weird. This might be
Print variable from external file. NameError: name ‘x’ is not defined
I would like to get that: if I select item A in the combobox of main.py, then the variable example is printed as placeholder in phrase (both are located in the external file external.py). So I would like to simply get the phrase of external.py to be printed in the textbox in main.py. The problem is that phrase is in
Continue in if conditional python loop is not working
Results are I was expecting that it would identify the first pattern DS in the first string in list a, then move to next element. However, it proceed to identify DY as well. What am I doing incorrectly? Any help is appreciated. Thanks Answer Try to replace continue with break like this Output: Ńontinue actually means that you go to
Iterate and loop through certain nested values to use within JSON Data and Request URLs
I have an nested list that works as [[id, price], [id, price], [id, price], [id, price]] and I need to iterate through the [0] and the [1] value to use in the request url and json data respectively. I can’t get the variable to be used in the request url but the json data seems to work fine Answer have
Discord.py bot ignoring channel.message.id
I have a bot that every 1 to 12 hours sends a random message into a specific channel (the channel that the command !random is used in). A certain handful of these message are yes/no questions, and I want to make it that the bot will respond if somebody says yes/no. The code works, the issue is I want the
Python if statement not working correctly and no idea why
In my code I iterate through dataframes of each year to calculate the number of wins (increase between numbers) and losses (decrease between numbers), and the ratio of wins to losses. The loop I run correctly displays the right number of wins and losses in the dataframe they are eventually pushed to. However, when calculating the win/loss ratio, the if