‘BACKTICK_QUOTED_STRING__AT_key’ is not defined for Pandas Quering function

Trying to get a hold of pd.query function Getting a UndefinedVariableError: name ‘BACKTICK_QUOTED_STRING__AT_key’ is not defined for the below pandas python code. Where am i going wrong? Answer Try this : or

Python 3: Calculating percentage change with n number of values

I have a function which should calculate percentage increase / decrease between two values. The parameters in the function are original_value and new_value. Problem: I need the program to take n number of values, for example, six values, and then run the function on every pair of values. An example: The values are 1, 2, 3, 4, 5 and 6. I then need the program to calculate the avg. percentage change between 1 and 2, 2 and 3, 3 and 4, 4 and 5, and 5 and 6. I thought this would be best by making the aforementioned function, then

Python – How to create a delete function for user input?

I’ve been trying to create a program which allows users to view a text file’s contents and delete some or all of a single entry block. An example of the text’s file contents can be seen below: As such, the entry block refers to all lines without a horizontal space. Currently, my progress is at: The delete_function() is meant to delete the creature by: Name, which deletes the entire text block associated with the name Information, which deletes only the line of information I can’t seem to get the delete_creature() function to work, however, and I am unsure of how

Counting the number of triplets forming GP series in python

The problem statement is: You are given an array and you need to find number of triplets of indices(i,j,k) such that the elements at those indices are in geometric progression for a given common ratio, r and i<j<k. For example, arr=[1,4,16,64]. If r=4, we have [1,4,16] and [4,16,64] at indices (0,1,2) and (1,2,3). I have a solution but I am unable to understand it. Can anyone help me out? Answer The way this problem works is that it uses “dict” to keep a running count of each number in the array. Then, it uses “dictPairs” to keep a running count

Call many python functions from a module by looping through a list of function names and making them variables

I have three similar functions in tld_list.py. I am working out of mainBase.py file. I am trying to create a variable string which will call the appropriate function by looping through the list of all functions. My code reads from a list of function names, iterates through the list and running the function on each iteration. Each function returns 10 pieces of information from separate websites I have tried 2 variations annotated as Option A and Option B below Option A Option B Even though it is not seen, I continue to loop through the iteration by ending each loop

List and use the variables defined inside my own function

Suppose that I have a function like this one: Now can I use the a, bvariables? Even if foo() is not returning them like this? I know this is easy to do if foo was a class, but it’s not. Answer Even though you are saying you have a function, not a class, python is able to transcend those differences using callable classes. Those are normal classes whose instances can be called as normal functions while still maintaining an internal state. Here is a demonstration: In the above code snippet, you can think of Foo as a class that generates

how to access a dictionary from another function in the current function

I am trying to refer to the dictionary in function_one. I have tried to return the dictionary variables, and use the dictionary names as parameters and arguments. However, I am getting an error message saying that the dictionaries I am trying to access in function_two is not defined. Here is my simplified code: Basically, I am asking if the element chosen for input1 is in the dictionary in the previous function I want the program to change the total_cost value etc. Answer When you are calling the function_one(), you are not using the dictionaries returned by it. You can use

Problem: Squares of a Sorted Array | Can anyone lookout this code [closed]

Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 2 months ago. Improve this question Can anyone recorrect this code? Code is not working properly. The output should be a square sorted array. Example :Input: [-4,-1,0,3,10] Output: [0,1,9,16,100] I’m using Leetcode platform. Answer Accepted solution: If you still want to do like yours check if this can help:

How can I write “EvenWord” Recursive in Python [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 months ago. Improve this question We tried to solve the following problem with friends but we couldn’t come to a conclusion. How can we approach this question? The full question is: Even Words Problem: An even word is a word that contains an even number of copies of every letter. For example, the word “tattletale” is an even word, since there are four copies of

I get a IndexError: list index out of range Error

I´m having some troubles on my code, that implements a function that verifies the lenght of a string and return that string with or without spaces. If String b >= 15 return b If strinf < 15 return “number os spaces until len(b)2 + string b But I get a IndexError: list index out of range Error. I cannot figure out where or why. Traceback: ============= RESTART: C:UserspboDesktopTrab_04.py ============= ascii_letters = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ Traceback (most recent call last): File “C:UserspboDesktopTrab_04.py”, line 30, in o2.append(a(o1[e])) IndexError: list index out of range ============= ============= ============= ============= ============= Thanks a lot for any possible