Annoy pandas SettingWithCopyWarning,甚至试过loc [;,]

时间:2018-05-11 13:33:11

标签: python pandas

code_null.loc[:,'code'] = code_null['blockname'].apply(__f,args=(code_name,))

def __f(x, df):
    #markets = ['A','B']
    markets = ['A']
    for market in markets:
        code = df.loc[df.name==x,'code'].tolist()
    if code:
        return ','.join(code)
    else:
        return np.nan

始终获得SettingWithCopyWarning

.virtualenv/python3/lib/python3.6/site-packages/pandas/core/indexing.py:537: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

也尝试过:

 code_null.loc[:,'code'] = code_null.loc[:,'blockname'].apply(__f,args=(code_name,))

但得到同样的警告。

0 个答案:

没有答案