This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Multi-Page Chatnificent App Example | |
| ==================================== | |
| This file shows how to create a multi-page app with Chatnificent. | |
| Since Chatnificent is a subclass of Dash, you can use all Dash features | |
| including multi-page apps with the pages/ directory structure. | |
| Directory Structure: | |
| -------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # /// script | |
| # requires-python = ">=3.13" | |
| # dependencies = [ | |
| # "anthropic>=0.77.0", | |
| # "chatnificent>=0.0.10", | |
| # "dash-bootstrap-components>=2.0.4", | |
| # ] | |
| # /// | |
| import chatnificent as chat | |
| from anthropic.types import TextBlock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # /// script | |
| # requires-python = ">=3.12" | |
| # dependencies = [ | |
| # "dash", | |
| # "dash-bootstrap-components", | |
| # ] | |
| # /// | |
| from dash import Dash, html, dcc, Output, Input | |
| import dash_bootstrap_components as dbc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import plotly.express as px | |
| fig = px.line( | |
| stocks, | |
| x='date', | |
| template='plotly_white', | |
| y=stocks.columns[1:], | |
| color_discrete_sequence=cat_scale, | |
| labels={'y': 'stock price'}, | |
| height=600,) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import plotly.express as px | |
| import adviz | |
| import numpy as np | |
| import pandas as pd | |
| population = pd.read_html('https://en.wikipedia.org/wiki/List_of_countries_and_dependencies_by_population') | |
| pop = population[0][['Location', 'Population']].copy() | |
| flags = [] | |
| for country in pop['Location']: | |
| try: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import datetime | |
| import pandas as pd | |
| today = datetime.datetime.now(datetime.UTC).strftime('%Y_%m_%d') | |
| url_status_time = pd.concat( | |
| pd.read_json(f'/path/to/status_codes/{file}', | |
| lines=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import datetime | |
| import advertools as adv | |
| today = datetime.datetime.now(datetime.UTC).strftime("%Y_%m_%d") | |
| sitemap = adv.sitemap_to_df("https://example/sitemap.xml") | |
| adv.crawl_headers( | |
| sitemap["loc"], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| xpath = pd.read_html('https://advertools.readthedocs.io/en/master/advertools.code_recipes.spider_strategies.html') | |
| df = xpath[2].iloc[:, [1, 2]] | |
| df = df.assign(expression=[f'=textjoin("@@",100,IMPORTXML(A2,"{expression}"))' for expression in df['XPath Expression']]) | |
| display(df[['Suggested Name', 'expression']].T) | |
| df[['Suggested Name', 'expression']].T.to_clipboard(index=False) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Create anchors for all letters: | |
| import string | |
| print('<h3>' + ' '.join([f'<a href="#{letter}">{letter}</a>' for letter in string.ascii_uppercase]) + '</h3>') | |
| # Assuming you have a DataFrame with the columns "full_name" and "loc": | |
| for letter in string.ascii_uppercase: | |
| df = players_df[players_static['full_name'].str[0].eq(letter)] | |
| print() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import datetime | |
| import pandas as pd | |
| lastmod = datetime.datetime.now(datetime.UTC).strftime('%Y-%m-%d') | |
| url_list = [ | |
| 'https://nbastats.pro/player/Eric_Moreland', | |
| 'https://nbastats.pro/player/Marc_Iavaroni', | |
| 'https://nbastats.pro/player/Keith_Tower', | |
| 'https://nbastats.pro/player/Hakeem_Olajuwon', | |
| 'https://nbastats.pro/player/Mike_Price', | |
| 'https://nbastats.pro/player/Doug_Collins', |
NewerOlder