<jupyter_start><jupyter_text>Setup<jupyter_code>!pip install -U requests lxml pandas requests
import pandas as pd
import requests

def get_html_page(url):
    return requests.get(url).text

pd.options.display.float_format = '{:.2f}'.format

page_data = get_html_page("https://www.fundsexplorer.com.br/ranking")

df = pd.read_html(page_data)[0]
df.columns = [
    "Código",
    "Setor",
    "Preço Atual",
    "Liquidez Diária",
    "Dividendo",
    "Dividend Yield",
    "DY (3M) Acumulado",
    "DY (6M) Acumulado",
    "DY (12M) Acumulado",
    "DY (3M) Média",
    "DY (6M) Média",
    "DY (12M) Média",
    "DY Ano",
    "Variação Preço",
    "Rentab. Período",
    "Rentab. Acumulada",
    "Patrimônio Líq.",
    "VPA",
    "P/VPA",
    "DY Patrimonial",
    "Variação Patrimonial",
    "Rentab. Patr. no Período",
    "Rentab. Patr. Acumulada",
    "Vacância Física",
    "Vacância Financeira",
    "Quantidade Ativos",
]

df["P/VPA"] = df["P/VPA"] / 100
df.replace(["%", "\.", "R\$"], "", regex=True, inplace=True)
df.replace(",", ".", regex=True, inplace=True)
df.sort_values(by=["P/VPA", "Dividend Yield"], inplace=True, ascending=[True, False])<jupyter_output><empty_output><jupyter_text>Edite a lista de FII's<jupyter_code>fiis = [
    "BCFF11",
    "BRCR11",
    "BTLG11",
    "HGCR11",
    "VRTA11",
    "GGRC11",
    "HCTR11",
    "FIIB11",
    "KISU11",
    "KNRI11",
    "MXRF11",
    "QAGR11",
    "TORD11",
    "XPLG11",
    "XPML11"
]
filtered_fiis = df[df["Código"].isin(fiis)]
selected_columns = filtered_fiis[["Código", "Setor", "Preço Atual", "Dividend Yield", "DY (3M) Média", "DY (6M) Média", "DY (12M) Média", "VPA", "P/VPA"]]
selected_columns['Nota'] = ((1 / selected_columns['P/VPA']) * pd.to_numeric(df["DY (3M) Média"], downcast="float")) * 10
selected_columns.sort_values(by=["Nota"], inplace=True, ascending=[False])
selected_columns<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1941952506596306, 'fraction_numerical': 0.02691292875989446, 'mean_word_length': 3.9763779527559056, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '480201', 'license': 'MIT', 'n_tokens_mistral': 873, 'n_tokens_neox': 826, 'n_words': 147, 'path': 'fii.ipynb', 'repo_name': 'jairhenrique/fii', 'size': '1895'}