【发布时间】:2016-11-14 07:33:04
【问题描述】:
我正在尝试在两个数据框中查找字符串值,并且我正在使用 Pandas 库。
第一个数据帧 - df_transactions 在“ErrList”列中有一个错误代码列表
第二个数据框 - df_action 在“CODE”列中有一个错误列表,在“ACTION”列中有相应的错误。
我正在尝试比较这些数据帧中的两个字符串,如下所示:
ActionLookup_COL = []
ActionLookup = []
for index, transactions in df_transactions.iterrows():
errorList = transactions['ErrList']
for index, errorCode in df_action.iterrows():
eCode = errorCode['Code']
eAction = errorCode['Action']
if eCode ==errorList:
ActionLookup.append(eAction)
ActionLookup_COL.append(ActionLookup)
df_results['ActionLookup'] = pd.Series(shipmentActionLookup_COL, index=df_results.index)
当我打印数据帧 df_results['ActionLookup'] 时,我没有得到与错误代码对应的操作代码。请让我知道如何比较这些数据框中的字符串
感谢您的宝贵时间!
【问题讨论】:
标签: python string pandas dataframe