lambda

Copy and Rename files in S3 bucket Lambda

Copy and Rename files in S3 bucket Lambda Question: I am writing a lambda function to test the tables in Athena and I have gotten that part to work. I am trying to rename the ResultConfiguration outputlocation file name that the function creates which cannot be renamed unless it’s copied and deleted. I am getting …

Total answers: 1

Pandas group events close together by date, then test if other values are equal

Pandas group events close together by date, then test if other values are equal Question: Based on the date of disease, and an address, I am looking for disease outbreaks that occur at the same location within specified timeframe of each other. The dataframe is large – 300K rows. There is a great solution to …

Total answers: 2

change iterrows() to .loc for large dataframes

change iterrows() to .loc for large dataframes Question: I have 2 data frames, df1 and df2. Based on the condition in df1 that day_of_week == 7 we have to match 2 other column values, (statWeek and statMonth) if the condition matches then we have to replace as_cost_perf from df2 with cost_eu from df1. in other …

Total answers: 3

Empty List prints when trying to use a lambda mapping function on a filtered list

Empty List prints when trying to use a lambda mapping function on a filtered list Question: The problem I am working on requries the use of lambda mapping and filtering. The code should take the input array of arrays, filter out any negative values, and then square the remaining values. In the code below, the …

Total answers: 1

TypeError when using ">=" in a lambda filter and trying to print in list form

TypeError when using ">=" in a lambda filter and trying to print in list form Question: I need to create a function that uses lambda filtering and mapping to go over an array of arrays and performs a calculation on them. The first step is to drop the negative numbers from each array. I was …

Total answers: 1

How to calculate relative values based on position of reference flag

How to calculate relative values based on position of reference flag Question: I have some simple table with IsReference column defining the flag indicating the base value of Pmpp based on which relative values for all other values of Pmpp grouped by Item should be calculated, as shown in the picture below. Similarly, I could …

Total answers: 2

Can't understand the lambda function inside the sorted() key argument

Can't understand the lambda function inside the sorted() key argument Question: I have to sort a string in this order: All sorted lowercase letters are ahead of uppercase letters. All sorted uppercase letters are ahead of digits. All sorted odd digits are ahead of sorted even digits. For instance, when the input is "Sample6789", the …

Total answers: 2

Why calling assigned lambda is faster than calling function and lambda (not assigned)?

Why calling assigned lambda is faster than calling function and lambda (not assigned)? Question: Why calling an assigned lambda in python3.11 is faster than: calling function lambda that isn’t assigned Why this happens only (maybe) on python 3.11 and not 3.7? I tried this: Python 3.11.2 (tags/v3.11.2:878ead1, Feb 7 2023, 16:38:35) [MSC v.1934 64 bit …

Total answers: 1

Python: Counting characters and displaying them in alphabetical order?

Python: Counting characters and displaying them in alphabetical order? Question: So I have to program something in Python that takes a string that’s 20 characters or more, count how often each character comes up, and display the count in Alphabetical order with caps and lowercase letters mixed (A-a-B-b-C-c). The phrase I’m testing is "She sells …

Total answers: 2