Data1234
Data1234

Reputation: 97

How to extract whole row using .isin function?

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'])]

Upvotes: 0

Views: 277

Answers (1)

scr
scr

Reputation: 131

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.

Upvotes: 1

Related Questions