Commit e75ed505 authored by 张鹏程's avatar 张鹏程

更新:

更新数据对比
三方数据源用户验证及调用
parent 69dbd14e
This diff is collapsed.
......@@ -2352,7 +2352,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.5"
"version": "3.6.0"
}
},
"nbformat": 4,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -43,8 +43,6 @@ def get_Loan_rollBack(df_loan,apply_time,passdueDay_Negative=False):
df_loan['observationTime'] = apply_time
# df_loan = df_loan.loc[(df_loan['apply_time'] < df_loan['observationTime']) & (df_loan['loan_paid_at'] < df_loan['observationTime'] )]
df_loan['repaid_at'] = df_loan['repaid_at'].apply(lambda x : datetime.datetime.strptime(datetime.datetime.strftime(x,'%Y-%m-%d %H:%M:%S'),'%Y-%m-%d %H:%M:%S'))
df_loan['deadline'] = df_loan['deadline'].apply(lambda x : datetime.datetime.strptime(datetime.datetime.strftime(x,'%Y-%m-%d 00:00:00'),'%Y-%m-%d 00:00:00'))
df_loan['deadline'] = df_loan['deadline'].apply(lambda x : datetime.datetime.strptime(datetime.datetime.strftime(x,'%Y-%m-%d 00:00:00'),'%Y-%m-%d 00:00:00'))
......
......@@ -55,7 +55,7 @@ if __name__ == "__main__":
from tornado.options import define, options
define("port", default=23018, help="run on the given port ", type=int)
define("port", default=23010, help="run on the given port ", type=int)
define("log_path", default='/tmp', help="log path ", type=str)
tornado.options.parse_command_line()
app = apps()
......
......@@ -285,8 +285,6 @@ def dict_generator_tongdun(indict, pre=None):
yield indict
def str_connect(x,y):
return str(x)+'_'+str(y)
def del_diff_columns(old_columns,new_columns,df):
"""并修改名称,返回修改后的名称"""
......@@ -331,7 +329,8 @@ def bytesToStr(x):
return x
def str_connect(x,y):
return str(x)+'_'+str(y)
from collections import defaultdict
reDict = defaultdict(int) # 返回错误计数,用于出测试报告图表
......@@ -351,7 +350,7 @@ def assert_diff(x,y,col_name,code=None):
else:
if code:
reDict['error'][code]+=0
return True
return
except:
pass
......@@ -368,7 +367,7 @@ def assert_diff(x,y,col_name,code=None):
if code:
reDict[code]['pass']+=1
reDict[code]['sum']+=1
return True
return
except Exception as e:
pass
......@@ -380,18 +379,17 @@ def assert_diff(x,y,col_name,code=None):
reDict[code]['sum']+=1
return False
else:
# print(col_name,'---',str(x) ,' ---- ',str(y))
reDict[col_name]+=1
return col_name+' : '+str(x)+'_'+str(y) + '\n'
else:
if code:
reDict[code]['pass']+=1
reDict[code]['sum']+=1
return True
return
except:
pass
def assert_columns(df,columns,not_columns=[],is_AssertFilter=True,is_reDict = False,is_DelColumnsXY = True,code=None):
""" 校验Dataframe columns 的 x 和 y 列
not_columns : 不参与校验的列
......@@ -399,9 +397,10 @@ def assert_columns(df,columns,not_columns=[],is_AssertFilter=True,is_reDict = Fa
is_reDict: 默认不返回总结信息
is_DelColumnsXY : 默认删除 columns 的 x和y
code : 提取某列作为错误统计
"""
df['测试结论'] = False
df.fillna(False,inplace=True)
df['测试结论'] = 'False'
df['测试描述'] = ""
global reDict
reDict = defaultdict(int)
......@@ -417,11 +416,11 @@ def assert_columns(df,columns,not_columns=[],is_AssertFilter=True,is_reDict = Fa
if cls not in ['测试结论'] + not_columns :
try:
if code:
df['测试结论'] = df.apply(lambda x : assert_diff(x[cls+'_x'],x[cls+'_y'],cls,x['code']),axis=1).astype(str)
_assert = df.apply(lambda x : assert_diff(x[cls+'_x'],x[cls+'_y'],cls,x['code']),axis=1)
df['测试描述']+=_assert.fillna('').astype(str)
else:
df['测试结论'] = df.apply(lambda x : assert_diff(x[cls+'_x'],x[cls+'_y'],cls),axis=1).astype(str)
_assert = df.apply(lambda x : assert_diff(x[cls+'_x'],x[cls+'_y'],cls),axis=1)
df['测试描述'] += _assert.fillna('').astype(str)
df[cls] = df.apply(lambda x : str_connect(x[cls+'_x'],x[cls+'_y']),axis=1)
if is_DelColumnsXY:
del df[cls+'_x']
......@@ -429,11 +428,14 @@ def assert_columns(df,columns,not_columns=[],is_AssertFilter=True,is_reDict = Fa
except:
pass
if is_AssertFilter:
df = df.loc[df['assert']!=True]
df = df.loc[df['测试结论']!=True]
df['测试描述'] = df['测试描述'].apply(lambda x : x.strip('\n').strip(' '))
df.loc[df['测试描述'] == '','测试结论'] = True
if is_reDict:
return df,dict(reDict)
else:return df
def matching_data(df,key):
"""
feature 特征匹配规则
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment