python_数据筛选查询 #显示使用了优惠券消费的商品,正样本 t2 = merchant3 [( merchant3 . date != 0 ) ( merchant3 . coupon_id != 0 )][[ 'merchant_id' ]] print ( 'df_crm' ) print ( df_crm [ df_crm . cust_isn == 81028650676
python_数据筛选查询
#显示使用了优惠券消费的商品,正样本t2 = merchant3[(merchant3.date!=0)&(merchant3.coupon_id!=0)][['merchant_id']]
print('df_crm')
print(df_crm[df_crm.cust_isn==81028650676])
print('\ndf_acct')
print(df_acct[df_acct.XACCOUNT==2754601])
#包含
df_train_stma.loc[df_train_stma.DAY_OPENED.isnull() & df_train_stma.PAYMT24.str.contains('1'),:]
df_train_stmt.loc[(df_train_stmt.delt2==0) & (df_train_stmt.AGE1>0),:]
#排序
df_train_stmt.loc[df_train_stmt.XACCOUNT==2757952.0,:].sort_values('delt2')
#筛选几列
#读取txt文件
df_apma=pd.read_csv('apma_poc.txt',encoding='gbk',dtype={'ACCOUNT':int}) # 申请件纪录
#选择出某几列,筛选几列 重新命名列名
sample = df_apma.loc[df_apma.DECCAN_CDE=='A',['ACCOUNT','MICROFILM','APPDEC_DAY']]
sample.columns = ['ACCOUNT','MICROFILM','APPDEC_DAY']
# 筛选 并选部分列 去重
cust_isn_list = data.loc[(data.purchase_date.dt.month == data.last_etl_acg_dt.dt.month+1)&(data.dqck_cur_balance>10000),
['cust_isn','purchase_date','purchase_account']].drop_duplicates()