#Hello i have 2 dataframes as per below
!pip install yahoo_earnings_calendar
import pandas as pd`enter code here`
from datetime import datetime
from datetime import timedelta
from yahoo_earnings_calendar import YahooEarningsCalendar
import dateutil.parser
#setting the report date
report_date = datetime.now().date()
#downloading the earnings calendar
yec = YahooEarningsCalendar()
earnings_list = yec.earnings_on(report_date)
#saving the data in a pandas DataFrame
earnings_df = pd.DataFrame(earnings_list)
Printing out earnings_df will give me daily stock earnings under Yahoo.
However if i only want the stock tickers for SNP for example,how do i extract only those tickers that fall under S&P , dow jones or nasdaq ?
The below code provides me with ah list of snp stock tickers.
table=pd.read_html('https://en.wikipedia.org/wiki/List_of_S%26P_500_companies')
snp = table[0]
snp= snp['Symbol']
print(snp)
How do i compare the 'Symbol' column in snp from 'ticker' column in earnings_list and only sift out the symbols in snp from the earning_list ?
thanks.
earnings_df[earnings_df['Ticker'].isin(snp)]
should do the job. – maow