This is a follow up question I read just now : DataFrame, apply, lambda, list comprehension.
So I tried the following code
import pandas as pd
# This is a dataframe containing the correct values
correct = pd.DataFrame([{"letters":"abc","data":1},{"letters":"ast","data":2},{"letters":"bkgf","data":3}])
# This is the dataframe containing source data
source = pd.DataFrame([{"c":"ab"},{"c":"kh"},{"c":"bkg"}])
temp_result = source["c"].apply(lambda x: i for (i,row) in correct.values)
So i tried different variations like this
temp_result = source["c"].apply(lambda x: i for (i,row) in correct.iteritems())
Yet all return the error :Genrator object is not callable
So my question is why is it returning a generator instead of treating it as a list of items ? I know what generator expressions are, but I am not able to understand why this expression is being treated as a generator instead of a list comprehension (or a lambda expression )?