Options

I am trying to implement Peer Logic in Rapidminer

sgnarkhede2016sgnarkhede2016 Member Posts: 152 Contributor II
edited September 2020 in Help
Hello,
I want to build Peer logic in Rapidminer,I have done with Python but not understanding how to do it in Rapidminer.
for Reference, I have attached my python code


def peer(df):
    input_df=df[['fy','sic', 'name','RevenueTotalR']]
    input_df['percnt']=input_df['RevenueTotalR']*20//100
    input_df['below_percnt']=input_df['RevenueTotalR']-input_df['percnt']
    input_df['above_percnt']=input_df['RevenueTotalR']+input_df['percnt']
    
    appended_data = []
    
    for y in input_df['fy'].unique().tolist():
        yr_df= input_df[input_df['fy']==y]
    #yr_df=input_df[input_df['fy'].astype(str)=='2017']
        for yr in yr_df['sic'].unique().tolist():
            sic_df=yr_df[yr_df['sic']==yr]
            for index_1,i in sic_df.iterrows():
                for index_2,j in sic_df.iterrows():
                    if i['name']!=j['name']:                        
                        if i['RevenueTotalR']>=j['below_percnt'] and i['RevenueTotalR']<=j['above_percnt']:
                            print(i['name'],'==',j['name'])
                            print(index_1)
                            i['peer_name']=j['name']
                            appended_data.append(i)
                        else:
                            pass
                        #print(index_1)
                        #print('FLASE')
    appended_data_new=pd.DataFrame(appended_data)


Expected Output:
fy sic name RevenueTotalR percnt below_percnt above_percnt peer_name
2011 7372 3D SYSTEMS CORP 230423000 46084600 184338400 276507600 ULTIMATE SOFTWARE GROUP INC
2011 7372 ULTIMATE SOFTWARE GROUP INC 269197992 53839598 215358394 323037590 3D SYSTEMS CORP
2011 3823 HICKOK INC 5082963 1016592 4066371 6099555 ELECTRO SENSORS INC
2011 3841 BECTON DICKINSON & CO 7828903936 1565780787 6263123149 9394684723 STRYKER CORP
2011 3841 STRYKER CORP 8306999808 1661399961 6645599847 9968399769 BECTON DICKINSON & CO
2011 7389 REIS, INC. 27180480 5436096 21744384 32616576 MONEYGRAM INTERNATIONAL INC
2011 7389 WESTERN UNION CO 5491399936 1098279987 4393119949 6589679923 MASTERCARD INC
2011 3674 AWARE INC /MA/ 24586000 4917200 19668800 29503200 QUICKLOGIC CORPORATION
2011 3674 QUICKLOGIC CORPORATION 20969000 4193800 16775200 25162800 AWARE INC /MA/
Sign In or Register to comment.