If I run the standard query from the help, i get mixed up data back. i am new to python/pandas so it might be just me...
Any ideas?
# Setup SQLAlchemy query to screen stocks based on PE ratio
# and industry sector. Then filter results based on
# market cap and shares outstanding.
# We limit the number of results to num_stocks and return the data
# in descending order.
fundamental_df = get_fundamentals(
query(
# put your query in here by typing "fundamentals."
fundamentals.valuation_ratios.pe_ratio,
fundamentals.asset_classification.morningstar_sector_code
)
.filter(fundamentals.valuation.market_cap != None)
.filter(fundamentals.valuation.shares_outstanding != None)
.order_by(fundamentals.valuation.market_cap.desc())
.limit(num_stocks)
)
from the debugger, the PE and Sector_code looks mixed up, duplicated for some stocks, just doesnt look right
fundamental_df
fundamental_df: DataFrame
0_Security(24 [AAPL]): Series
0_pe_ratio: 13.947
1_morningstar_sector_code: 311.0
1_Security(8347 [XOM]): Series
0_pe_ratio: 311.0
1_morningstar_sector_code: 13.947
2_Security(26578 [GOOG_L]): Series
0_pe_ratio: 13.947
1_morningstar_sector_code: 311.0
3_Security(5061 [MSFT]): Series
0_pe_ratio: 311.0
1_morningstar_sector_code: 13.947
4_Security(1091 [BRK_A]): Series
it might be the debugger because when i run this
fundamental_df.iloc[0,:]
the values look correct
fundamental_df.iloc[0,:]
fundamental_df.iloc[0,:]: Series
0_Security(24 [AAPL]): 13.947
1_Security(8347 [XOM]): 13.7174
2_Security(26578 [GOOG_L]): 62.1118
3_Security(5061 [MSFT]): 13.8313
4_Security(1091 [BRK_A]): 15.015
5_Security(3149 [GE]): 19.084
6_Security(11100 [BRK_B]): 14.2857
7_Security(4151 [JNJ]): 19.0476
8_Security(8229 [WMT]): 15.4083
9_Security(23112 [CVX]): 11.2613
10_Security(8151 [WFC]): 11.6686
11_Security(27470 [RDS_B]): 14.43