Python:应用依赖于两列数据输入的函数

时间:2019-03-28 15:46:24

标签: python function apply

我正在使用apply函数来标记数据的方向,但是收到以下警告:

2_seq_preprocess.py:71: 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

我需要帮助,将其转换为具有两列输入信息的格式,而不仅仅是我所描述的。

#make a function to determine orientation values in each row

def orient(row):
    if row['sstart'] < row['send']:
        val='+'
    else:
        val='-'
    return val

#input orientation values
#useq.loc[useq['sstart']>useq['send'],'orientation'] = '+'
#useq.loc[useq['sstart']<useq['send'],'orientation'] = '-'

useq['orientation']=useq.apply(orient,axis=1)

0 个答案:

没有答案