After days of trying, I still can't format the 'mktCap' to make it easier to read (either add in commas or convert it to million). My code is as below:
pip install FundamentalAnalysis
import pandas as pd
import FundamentalAnalysis as fa
pd.set_option('display.max_colwidth',0)
pd.options.display.float_format = '{:,.2f}'.format
ticker = 'AAPL'
api_key = "04d9e13fe10d09ef72be8bbd0e21262e"
# Collect general company information
profile = fa.profile(ticker, api_key)
print(profile.loc[['symbol','companyName','mktCap','range','changes',\
'exchangeShortName','industry','sector','description',\
'ceo','fullTimeEmployees','state','isActivelyTrading']])
print('')
# Show the growth of the company
growth_annually = fa.financial_statement_growth(ticker, api_key, period="annual")
nig = growth_annually.loc['netIncomeGrowth']
# Show a large set of in-depth ratios
financial_ratios_annually = fa.financial_ratios(ticker, api_key, period="annual")
dy = financial_ratios_annually.loc['dividendYield']
pe = financial_ratios_annually.loc['priceEarningsRatio']
npm = financial_ratios_annually.loc['netProfitMargin']
roe = financial_ratios_annually.loc['returnOnEquity']
cf = financial_ratios_annually.loc['freeCashFlowOperatingCashFlowRatio']
atr = financial_ratios_annually.loc['assetTurnover']
em = financial_ratios_annually.loc['companyEquityMultiplier']
df = pd.DataFrame([nig, dy, pe, npm, roe, cf, atr, em])
df['Ult + DuPont'] = ['G:Net Inc Gr', 'D:DY', 'P:P/E', 'P:NPM', 'R:ROE', \
'C:Free CF/Op CF','Asset Turnover','Equity Mult']
df = df.set_index('Ult + DuPont')
print(df[df.columns[:5]])
print('')
# Obtain DCFs over time
dcf_annually = fa.discounted_cash_flow(ticker, api_key, period="annual")
dcf_quarterly = fa.discounted_cash_flow(ticker, api_key, period="quarter")
print(dcf_annually.iloc[:,:5])
print('')
print(dcf_quarterly.iloc[:,:5])
print('')
# Show recommendations of Analysts
ratings = fa.rating(ticker, api_key)
print(ratings)
print('')
May I know how to convert the reading for 'mktCap' to make it easier to read? Thanks.
What I have tried:
numerize
millify
prettify
astype
pd.to_numeric