How to extract whole row using .isin function?

Question:

So I had a dataframe that had 5000 rows and 40 columns. After some analysis I had to do it was reduced to 3000 rows and 8 columns. Now my problems is that I want to extract the entire row from the old dataframe but I make a mistake not following through with the index and I cannot use it to extract them. Is there another way to do it?

so far I have tried this. Is there anything I can do to this function to extract the whole row?

a=df_unique[df_unique['CUSTOMERID'].isin(df['CUSTOMERID'])]
Asked By: Data1234

||

Answers:

Sounds like you just need to do an inner join:

import pandas as pd
result_df = pd.merge(new_df, old_df, on='CUSTOMERID', how='inner')

Please let me know if this solves your problem.

Answered By: scr
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.