library('reticulate')
use_condaenv(condaenv = 'STOCK_MASTER', required = TRUE)
::opts_chunk$set(echo = TRUE, cache = TRUE) knitr
import pandas as pd
import numpy as np
= pd.read_csv('https://raw.githubusercontent.com/Brent-Morrison/Misc_scripts/master/stock_data.csv')
df_raw 'date_stamp'] = pd.to_datetime(df_raw['date_stamp'], format="%d/%m/%Y") df_raw[
Select columns and date required
= df_raw[df_raw['date_stamp'] == '2021-06-30'][['symbol','date_stamp','sector','asset_growth','roa','roe','leverage','ttm_earnings']] df
=['sector','ttm_earnings'], ascending=[True,False], inplace=True) df.sort_values(by
= df.groupby('sector').head(5).reset_index(drop=True).copy() df
::paged_table(py$df) rmarkdown