i have a .csv files which contains many data and i want to compare that with another .csv file and based on that i want to have an output file, for example my first file contains the data in following manner :-
and the second .csv file which named as second file, contains the list of the diseases which we need for example -:
so based on that our output file should be -:
i have written the python code for that, but i'm not getting the desired result, Please have a look-:
import pandas as pd
import numpy as np
df=pd.read_csv("final.csv")
df1=pd.read_csv("diseases.csv")
df =df[df['extId'].isin(df.loc[df['Diseases'].isin(df1), 'extId'])]
df.to_csv("filtered.csv")


