dpguthrie / dpguthrie/yahooquery
fund_top_holdings mixes results
- Dominant language
- Python
- Stars
- 920
- Forks
- 164
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
When you download more tickers and some tickers are not ETFs (so do not have holdings), Dataframe with a result attach further holdings to previous tickers
**To Reproduce**
Steps to reproduce the behavior:
tickers: SCHD, AAPL, SPY, MSFT, QQQ
result of fund_top_holdings (looks like MSFT has holdings)
/usr/local/lib/python3.10/dist-packages/yahooquery/ticker.py:143: FutureWarning: The behavior of pd.concat with len(keys) != len(objs) is deprecated. In a future version this will raise instead of truncating to the smaller of the two sequences
df = pd.concat(
symbol holdingName holdingPercent
symbol row
SPY 0 AAPL Apple Inc 0.072550
1 MSFT Microsoft Corp 0.065502
2 NVDA NVIDIA Corp 0.061181
3 AMZN Amazon.com Inc 0.035645
4 META Meta Platforms Inc Class A 0.025613
5 GOOGL Alphabet Inc Class A 0.019901
6 BRK-B Berkshire Hathaway Inc Class B 0.017267
7 GOOG Alphabet Inc Class C 0.016446
8 AVGO Broadcom Inc 0.016445
9 TSLA Tesla Inc 0.014867
MSFT 0 HD The Home Depot Inc 0.042606
1 VZ Verizon Communications Inc 0.042086
2 CSCO Cisco Systems Inc 0.041486
3 BLK BlackRock Inc 0.041464
4 TXN Texas Instruments Inc 0.039868
5 PFE Pfizer Inc 0.039848
6 CVX Chevron Corp 0.039825
7 BMY Bristol-Myers Squibb Co 0.039628
8 LMT Lockheed Martin Corp 0.039401
9 KO Coca-Cola Co 0.038476
SCHD 0 AAPL Apple Inc 0.090193
1 MSFT Microsoft Corp 0.081431
2 NVDA NVIDIA Corp 0.075843
3 AVGO Broadcom Inc 0.052568
4 META Meta Platforms Inc Class A 0.050655
5 AMZN Amazon.com Inc 0.049790
6 TSLA Tesla Inc 0.032210
7 COST Costco Wholesale Corp 0.025845
8 GOOGL Alphabet Inc Class A 0.024740
9 GOOG Alphabet Inc Class C 0.023773
**Expected behavior**
No holdings = Nan or False
**Desktop (please complete the following information):**
- OS: Ubuntu
- Version not known :/
Contributor guide
Research direction
Start in ticker.py around line 143 and trace fund_top_holdings with SCHD, AAPL, SPY, MSFT, and QQQ. Reproduce the concatenation warning and verify that non-ETF tickers do not receive another ticker's holdings; done means missing holdings are represented as NaN or False.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100