5
Come ridurre un dato con la stringa più lunga sotto il framework pandas? Ho provato il seguente codice, ma ottengo ValueError: invalid number of arguments
.Come ridurre un dato con la stringa più lunga sotto il framework pandas?
def f1(s):
return max(s, key=len)
data.groupby('id').agg({'name':(lambda s: f1(s)) })
Es. Ingresso
id name
GB "United Kingdom"
GB England
US "United States"
US America
uscita:
id name
GB "United Kingdom"
US "United States"