Skip to content Skip to sidebar Skip to footer

Python Pandas Checking For A Value If It Exists From One Dataframe To Another Dataframe

I have an Excel file in which I use each columns as DataFrame. Here are the 5 DataFrames that I am using - (I will be adding a row number column for easier clarification in my ques

Solution 1:

I answered this by doing: I used df.loc for each row following.

I was able to achieve my output without grouping the two rows that contains the transposed value.

In line (df['svc_no']isint(df['caller_id'])), I locate if the value exists in svc_no in caller_id and created another df.loc for the other other row

Scenario 1:

df.loc[(c_merge['svc_no'] != 'NULL') & /
      (df['i_status'] == 'WO') & /
      (df['caller_id'] != 'n/a') & /
      (df['f_status'] == 'WO') & /
      (df['svc_no'] != df['caller_id']) & /
      (df['svc_no'].isin(df['caller_id'])), ['remarks']] = 'S1 Transpose'

df.loc[(c_merge['svc_no'] != 'NULL') & /
      (df['i_status'] == 'WO') & /
      (df['caller_id'] != 'n/a') & /
      (df['f_status'] == 'WO') & /
      (df['svc_no'] != df['caller_id']) & /
      (df['caller_id'].isin(df['svc_no'])), ['remarks']] = 'S1 Transpose'

I will apply this to the other scenarios as I think this is the way to it.

Post a Comment for "Python Pandas Checking For A Value If It Exists From One Dataframe To Another Dataframe"