I have a dataframe (testdata
) of 1 column with n rows that each contain a string. I want to send all to an API and store the result in the next column. But the API where I can send lists to analyze something (like ["Test1"],["Test2"]
) has a limit of 20 elements per call, that's why i wanted to write a function that for each row/cell sends the string element (doc
) to the API and stores the result in a new column via the apply-function.
testdata
def API(doc):
result = APIclient.analyze(doc, language="en")
return result
API(["Test1"],["Test2"])
#testdata["Response"] = testdata.apply(API, axis = 1)
Right now, the function works if applied to lists like here (API(["Test1"],["Test2"])
) but if i want to apply it to every row my column i get the typical The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
-error. Does anyone know how to solve this? Thanks!