function

How do I get a function's output characters to be automatically counted in python?

How do I get a function's output characters to be automatically counted in python? Question: I am trying to print the number of characters that are present in the output my function gives. in this case I’m looking for 90 as "lowercase" 10 times is 90 characters. I’m not really sure what to try, please …

Total answers: 1

Passing column name to python function

Passing column name to python function Question: I have created a function that does something like this that accepts a pandas dataframe and a column name. def summaryTable(df, cutoff, column): if cutoff == 1: df[column] = df.column.astype(str) When I do this I get an AttributeError, DataFrame object has no attribute ‘column’. Is there a way …

Total answers: 1

Function to trim a list and calculate mean of remaining numbers

Function to trim a list and calculate mean of remaining numbers Question: I need a function that takes a list of numbers as the input and an optional integer keyword argument trim (that takes on values of 0 or larger). I want to remove the largest and smallest numbers from the list and Return the …

Total answers: 5

Python function to count divisible numbers in a list?

Python function to count divisible numbers in a list? Question: I need to write a python function that takes a list as the input and calculates the number of numbers divisible by some other number, n. This is the code I have so far: enter image description here Could someone advice me on what approach …

Total answers: 2

How to turn list into nested in a specific way?

How to turn list into nested in a specific way? Question: I have a list: ["a", "b", "c", "d", "e", "f", "g"]. I want to make it nested and put in sublists of two consecutive values ​​from the given list. if there are no two values ​​left, then one value should go to the sublist. …

Total answers: 4

Returning unique values from a function in a for loop

Returning unique values from a function in a for loop Question: I have a logic problem that I’m struggling to get my head around. I’m currently processing some data, specimen by specimen. Each specimen has a data frame of raw data associated with it. A different number of specimens will be processed at the same …

Total answers: 2

Queries regarding print() function

Queries regarding print() function Question: print("Line 1") print(">>>") type(print("Hello")) print() print("Line 2") print(">>>") print(print("Hello")) print() print("Line 3") print(">>>") a = print("Hello") b = a print("a:", a, "b:", b) Q1) For Line 1, why is it that type(None) not be executed since print("Hello") returns None ? Q2) I am sort of aware that IIFE is a …

Total answers: 1

How to filter a dataframe by rows of another one?

How to filter a dataframe by rows of another one? Question: I have two dataframes: df1: id type "a" "alpha" "a" "alpha" "a" "beta" "a" "gamma" and df2: id type "a" "alpha" "a" "alpha" "a" "alpha" "a" "alpha" "a" "beta" "a" "beta" for each row in df1 i want to remove single row from df2 …

Total answers: 1

Variable is not accessed in Pylance

Variable is not accessed in Pylance Question: For some reason, I am receiving an error on VSCode that says the specific variable is not accessed Pylance and each variable says the same thing, Am I missing something simple? full code below: score = 0 def gen1_questions(): q1 = input("Question 1. What is the rarest M&M …

Total answers: 1