import pandas as pd
from great_tables import GT
import gt_extras as gte
= pd.DataFrame(
df
{"name": ["Great Tables", "Plotnine", "Quarto"],
"url": [
"https://posit-dev.github.io/great-tables/",
"https://plotnine.org/",
"https://quarto.org/",
],"github_stars": [2334, 4256, 4628],
"repo_url": [
"https://github.com/posit-dev/great-tables",
"https://github.com/has2k1/plotnine",
"https://github.com/quarto-dev/quarto-cli",
],
}
)
"Package"] = [
df[
gte.gt_hyperlink(name, url)for name, url in zip(df["name"], df["url"])
]
"Github Stars"] = [
df[=False)
gte.gt_hyperlink(github_stars, repo_url, new_tabfor github_stars, repo_url in zip(df["github_stars"], df["repo_url"])
]
"Package", "Github Stars"]]) GT(df[[
gt_hyperlink
=True) gt_hyperlink(text, url, new_tab
Create HTML hyperlinks for use in GT
object cells.
The gt_hyperlink()
function creates properly formatted HTML hyperlink elements that can be used within table cells.
Parameters
text : str
-
A string that will be displayed as the clickable link text.
url : str
-
A string indicating the destination URL for the hyperlink.
new_tab : bool = True
-
A boolean indicating whether the link should open in a new browser tab or the current tab.
Returns
: str
-
An string containing the HTML formatted hyperlink element.