I have a data frame of 15000 record which has text column (column name = clean) as a list, please refer below
I need to find the minimum value in each row and add as a new column called min
def find_min(x):
x = min(x)
return(x)
I tried to pass the above function
df1['min'] = df1['clean'].map(find_min)
Getting below error
ValueError: min() arg is an empty sequence
It seems there is an empty list, how to address this as I am having 15000 records Please advise
min
, so you no longer have access to the builtin min function in the current scope. Try renaming your outer function. Btw you could just dodf1['clean'].map(min)
without having to define a min function.min
already. 2: you're overwriting it. 3: you're callingmin(x)
from within the function itself, resulting in an infinite recursion.