0

I have for example in the dataframe daily "AAPL,MSFT,TSLA,AMZN" and in weekly list "OAG,EXCA,AAPL,HRT,TSLA"

How can i compare the two dataframes and print out when a ticker is found in both lists?

dailyList = []
weeklyList = []

for ticker in tickers:
 dailyList.append(ticker)
 weeklyList.append(ticker) # append with some data like "AAPL"

compare(dailyList,weeklyList)
print(matchingTickers)
Daniel
  • 75
  • 1
  • 7

1 Answers1

0

If you just want to compare the two list of tickers, you can try something like this:

daily =  set("AAPL,MSFT,TSLA,AMZN".split(","))
weekly = set("OAG,EXCA,AAPL,HRT,TSLA".split(","))
common = daily.intersection(weekly)

Here, common would be: {'TSLA', 'AAPL'}.

suvayu
  • 4,271
  • 2
  • 29
  • 35