我有一个数据框:
df = pd.DataFrame(
{'id': ['1', '2', '3', '4', '5', '6', '7', '8'],
'datetime': ['24.06.2013 00:13:49',
'24.06.2013 00:14:27',
'24.06.2013 00:17:45',
'24.06.2013 00:21:54',
'24.06.2013 00:21:59',
'24.06.2013 00:22:05',
'24.06.2013 00:25:14',
'24.06.2013 00:26:04'],
'card_num': ['10', '10', '27', '10', '34', '10', '7', '3'],
'type': ['cash_withdrawal',
'cash_withdrawal',
'refill',
'cash_withdrawal',
'payment',
'cash_withdrawal',
'payment',
'cash_withdrawal'],
'result': ['refusal',
'refusal',
'successful',
'refusal',
'successful',
'successful',
'successful',
'successful'],
'summ': [10000, 8000, 42431, 4000, 2347, 3500, 105, 999]})
要求发现类似欺诈交易,标准如下:
我已经做了以下工作:
df_report = df[(df.type != 'refill') & (df.result == 'successful')]
# left those lines where the type is not equal refusal and the result is successful
card = df_report.card_num
# get an array of these card numbers
suspicious = df[df.card_num.isin(card)]
# apply a filter to the main dataframe according
# to the condition that the cards of the main df are contained in the filtered cards
接下来,我需要移除卡上的操作是<;我不知道怎么做,你能告诉我吗? 此外,此数据帧需要通过结果列进行过滤,以便这些卡保持成功和拒绝
要查找重复分类值的连续运行,可以执行以下操作:
相关问题 更多 >
编程相关推荐