All Questions
Tagged with lambda python-3.x
799
questions
1
vote
1
answer
55
views
How to call a function from a function in a class that is called using a button with a lambda in Python3x?
I have a class: MyClassName for example, with two functions: one to calculate a number and one to validate if a group of comboboxes (tkinter) all have selections. I'm also using tkinter for a button ...
1
vote
1
answer
37
views
sorting a list of tuples using lambda, python [duplicate]
I have a list of tuples that contains (name, score).
I want to sort the list on the second element (reverse = True) and if two names are similar then sort it on first element but not using reverse.
I ...
0
votes
1
answer
34
views
TypeError: finance_tracker.create_widgets.<locals>.<lambda>() missing 1 required positional argument: 'col'
I am getting an error in the following code
class finance_tracker:
def __init__(self, root):
self.root = root
self.root.geometry("1000x550")
self.root.resizable(...
-1
votes
1
answer
28
views
pd dataframe applymap tries to modify col names
Hello i have a dataframe containing datetime infos and i'd like too format those infos so i've used this command :
df2[["month", "day", "hour", "min", "s&...
1
vote
1
answer
51
views
Partition by column, order by another
I am simulating a SQL query with the following values:
rows = [(1, '2021/04', 'Shop 2', 341227.53), (2, '2021/05', 'Shop 2', 315447.24), (3, '2021/06', 'Shop 1', 1845662.35), (4, '2021/04', 'Shop 2', ...
0
votes
0
answers
31
views
Flask endpoint to Lambda function
I have a bunch of endpoints in a utility Flask application. One endpoint is like this:
@app.route('/Terminal/Velocity', methods=["GET"])
def terminal():
if request.method != "GET&...
0
votes
0
answers
74
views
b'./bin/freshclam: error while loading shared libraries: libltdl.so.7: cannot open shared object file: No such file or directory\n'
Lmabda antivirus-update error.
b'./bin/freshclam: error while loading shared libraries: libltdl.so.7: cannot open shared object file: No such file or directory\n'
In the Dockerfile, the command &...
2
votes
1
answer
94
views
Why does using *kwargs.values() within a lambda function's parameter list result in a SyntaxError?
(lambda **kwargs: *kwargs.values())(a=1, b=2)
This code snippet raises a SyntaxError, specifically stating "invalid syntax" pointing to the use of the * operator within the parameter list ...
0
votes
0
answers
22
views
lambda function in key argument in sorted() method in python? [duplicate]
I found this code from online and tries to find what is the logic.But i didn't get it.
from collections import Counter
arr = [4,3,1,1,3,3,2]
k = 3
c = Counter(arr)
print(c)
s = sorted(arr,key = lambda ...
1
vote
1
answer
52
views
How to replace the outlier with 3 standard deviation value for all column based on group by column?
Hi I have data frame in which I want to replace/cap the outlier with the 3*standard deviation value for all column with group by for each column. For example:
df = pd.DataFrame({"A":["A&...
1
vote
2
answers
84
views
Simple lambda expressions in python but occurs error 'maximum recursion depth exceeded in comparison'
This is my code.
def div_by_primes_under(n):
checker = lambda x: False
i = 2
while i <= n:
if not checker(i):
# checker = (lambda f, i: lambda x: x % i == 0 or f(x))(...
2
votes
1
answer
39
views
Mapping strip() to strings in pandas dataframe does not change NaN entries but still claims that they are different?
I have a dataframe where I have very different kinds of entries (text, integers, floats, times, etc.) and I am trying to delete leading and trailing whitespaces from text entries so that my other code ...
0
votes
0
answers
42
views
List comprehension of lambdas generates identical functions [duplicate]
I want a list of functions where the ith function takes a vector as input and returns the ith element of that vector
n_functions = 10
func_list = [lambda z: z[i], for i in range(n_functions)]
However ...
1
vote
1
answer
216
views
Adding leading zeros to zipcodes that are less than 5 digits in pandas dataframe
I have a pandas dataframe that has a column of zipcodes and I want to add leading zeros to the zipcodes so they all have five digits.
This is the code I use which correctly identifies the values that ...
-2
votes
5
answers
270
views
Python Nested lambda function
Would there be a way to write a nested lambda function? The following is what I am trying to do:
s = '123 there'
f = lambda x: x.split()
g = lambda x: [int(x[0]), x[1]]
#g(f(s)) returns [123, 'there']...