The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Guest
DF
By Guest on 24th January 2023 01:32:27 PM | Syntax: TEXT | Views: 12



New paste | Download | Show/Hide line no. | Copy text to clipboard
  1. import pandas as pd
  2. df1=pd.read_csv("C:\\Users\\vivek.viswanathan02\\OneDrive - Infosys Limited\\Documents\\vv1.csv")
  3. df2=pd.read_csv("C:\\Users\\vivek.viswanathan02\\OneDrive - Infosys Limited\\Documents\\vv2.csv")
  4.  
  5. a=df1[df1['Station'].isin(df2['Keys'])]
  6. b=pd.merge(a,df2, left_on='Station',right_on='Keys',how='inner')
  7. b['Station']=b['Values']
  8. b.drop(['Keys','Values'],axis=1,inplace=True)
  9. c=pd.concat([a,df1]).drop_duplicates(keep=False)
  10.  
  11. out=pd.concat([b,c])
  12. print(out)



  • Recent Pastes
  • Questions
    12 hours 45 mins 42 secs ago
  • Adrs
    12 hours 50 mins 52 secs ago
  • Docs
    12 hours 51 mins 36 secs ago
  • Servs
    12 hours 52 mins 19 secs ago
  • Srvs
    12 hours 57 mins 8 secs ago