Can anybody explain me why this code should not work?
wordsCount = {}
def addWord(x):
print(x)
df.apply(addWord(x))
It return the error: TypeError: ("'NoneType' object is not callable", 'occurred at index 0') The dataframe df contains some None value in some cell. My intention is to apply a function to all non-None value.
.apply()expects a function, but you are passing it the return value by callingaddWord(x), which is None, since no return value is specified in theaddWordfunction. Just passaddWordwithout the parenthesis.