1

I have a data frame which has information on 1000 stocks (open, close, high , low, volume, company name, ticker symbol etc.) and I have another dataframe which just has one column of ticker symbols and this second dataframe has fewer rows than 1000 rows in the first dataframe. Now, I want only those rows in the first dataframe for which the ticker symbol is available in the second dataframe. How can this be done using pandas ? In my case, I have small dataframes. But I would also like to know how this operation can be scaled up. So, please suggest efficient way as well.

Thanks

1 Answer 1

2

You can use .isin() to filter to the list of tickers available in df2.

df1_filtered = df1[df1['ticker'].isin(df2['ticker'].tolist())]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.