Tell us what works and what could be better. We read every submission.
@adiamaan92·21 public vizzes
This example demonstrates an automated GitHub Actions workflow that scrapes speeches by Indian Prime Minister Narendra Modi on a daily schedule. The workflow, defined in a YAML file, runs a Python script named `scrapper.py` at 8 AM UTC using a cron trigger. It sets up Python 3.8, installs dependencies via Poetry, and caches the virtual environment to speed up subsequent runs. The scraper uploads data to Kaggle using credentials stored as GitHub secrets, with the workflow supporting both scheduled and manual execution through `workflow_dispatch`.
This visualization maps the geographic and thematic reach of Narendra Modi’s speeches, sourced from a Kaggle dataset of text speeches starting in 2018. It displays an interactive choropleth of India, with state boundaries drawn using `d3.geoPath` and a `d3.forceSimulation` layout that positions speech-related keywords as nodes. Hovering over a state reveals its name, while colored circles represent speech themes, with sizes scaled to frequency. The code uses D3.js for SVG rendering and transitions, and it loads the dataset from a JSON file, updating the visualization dynamically.
This example demonstrates how to update a dataset of speeches by appending new entries and committing the changes to a data repository. It shows the process of merging delta records with existing speech data using pandas, then saving the combined result to a CSV file. The code uses `pd.concat` to combine the DataFrames, `to_csv` to persist the updated file, and the `api.dataset_create_version` method from the data platform’s API to create a new version with a timestamped note. This workflow highlights automated data maintenance and version control for evolving datasets.
This example fetches a dataset of Indian Prime Minister Narendra Modi’s speeches from Kaggle using the `kaggle_api_extended.KaggleApi` class, specifically calling `dataset_download_files` to download and unzip the “modi-speeches” dataset. The code then reads the downloaded CSV file into a pandas DataFrame via `pd.read_csv` and extracts the first speech title from the `title` column. The visualization implicitly relies on the Kaggle API and pandas to retrieve and display the dataset’s content, but no charting or rendering library is shown beyond these data-access steps.
This example shows how to incrementally fetch newly published speech titles from the Narendra Modi website using direct API calls. It paginates through the site’s `loadspeeche` endpoint, parsing the returned HTML with `lxml`’s `etree` and XPath queries. The script stops fetching pages once it encounters a title matching the previously saved latest speech, avoiding redundant downloads. It then calls `get_article_data(tree)` on new entries, demonstrating a simple delta-extraction pattern for tracking content updates over time.
This visualization generates a Buddhabrot image by tracing the trajectories of non-Mandelbrot complex numbers. It shows the accumulated density of these trajectories across the complex plane, producing the characteristic fractal glow. The `generate_buddhabrot` function in NumPy starts with an array of points and iteratively squares each point and adds the original constant, mapping the resulting coordinates to an image array with `img_array[x, y] += 1`. It keeps only points with magnitude less than 2, looping until no points remain, and returns the final density array.
This example visualizes complex numbers that are not in the Mandelbrot set, showing the distribution of points that escape the set’s boundary. It generates random samples in the complex plane, first filtering out points inside the main cardioid and period-2 bulb using algebraic tests, then iterating the remaining points up to a maximum number of iterations. Points whose magnitude exceeds 2 are collected as non-Mandelbrot samples. The code uses NumPy’s array operations and masking to perform the filtering and iteration efficiently, returning a dense array of escaped complex coordinates.
This visualization generates a 500-by-500 Mandelbrot set by iterating the complex function z = z² + c for up to 100 iterations. It shows the divergence pattern of points on the complex plane between x from -2 to 1 and y from -1.5 to 1.5, using NumPy arrays and the `np.complex` constructor to store iteration counts. The nested loops directly compute each pixel’s escape time, with the `np.zeroes` array initializing the output grid before filling it with the final iteration values.
This example demonstrates how to configure custom font scripting in Visual Studio Code using a JSON settings file. It shows two textMate rules that stylize code elements: the first resets font styles for specific scopes like `invalid` and `keyword.operator`, while the second applies italics to keywords, comments, and Python-specific tokens. The configuration relies on VS Code’s `editor.tokenColorCustomizations` API, referencing TextMate grammar scopes to control typography. It pairs `Victor Mono` with `Fira Code` and enables font ligatures for enhanced readability.
This example demonstrates a utility function that renames the columns of a pandas DataFrame. It shows how to apply a custom naming scheme, such as joining multi-level column labels with an underscore, or replacing the column names with an explicit list. The function `setcols` accepts a DataFrame and an optional function or list; when no list is provided, it maps the given function across the existing column index. The code relies on pandas’ `columns` attribute and the `map` method, making it a concise tool for data preprocessing before visualization.
This example demonstrates how to filter the Iris dataset to retain only the sepal-related measurement columns. It defines a custom `cfilter` function that applies a lambda-based condition to either rows or columns, then pipes the dataset through a chain that first normalizes column names—converting them to lowercase, stripping units like "(cm)", and replacing spaces with underscores—before filtering columns. The visualization relies on pandas’ `pipe` method and string methods (`str.lower`, `str.replace`, `str.contains`) to transform and subset the data, showcasing a reusable pattern for column selection based on naming conventions.
This example demonstrates a Python helper function for logging during pandas DataFrame method chaining. The code defines `csnap`, which accepts a DataFrame, an optional function (defaulting to `lambda x: x.shape`), and an optional message, then prints the message and logs the function’s result via the `logging` module. It writes debug output to `mylog.log` using a `FileHandler` with a timestamped formatter, and returns the original DataFrame unchanged to preserve chaining. The snippet shows a debugging utility rather than a visual plot, relying on Python’s standard `logging` API.
This example demonstrates a data-cleaning workflow for the Iris dataset, showing how column names are standardized before further analysis. It uses pandas DataFrames with a custom `pipe`-based pipeline that chains operations: first, a `csnap` utility snapshots the initial data head labeled "Before"; then, a `setcols` function applies a lambda to transform column names by lowercasing, removing "(cm)" units, stripping whitespace, and replacing spaces with underscores; finally, a second snapshot shows the cleaned head labeled "After". The code relies on `load_iris()` from scikit-learn and pandas' `pipe` method for functional composition, making the before-and-after effect visible in the console output.
This example shows a step-by-step transformation of the classic wine dataset, progressively filtering and selecting columns to isolate alcohol content, color intensity, and hue before randomly sampling five rows. The code chains pandas operations—including `rename`, `assign`, `query`, and `sort_values`—through a custom `csnap` helper that snapshots the intermediate state after each step. It uses NumPy’s `np.where` to create a binary `color_filter` column based on hue and color intensity thresholds, then resets the index and samples five rows with `sample(5)`. The visualization highlights how pipelined data wrangling can be inspected at each stage.
This visualization demonstrates a method-chaining utility for pandas DataFrames, allowing users to inspect intermediate data states during complex transformations. The `csnap` function takes a DataFrame, an optional transformation function, and a message, displaying the result of applying that function to the data while returning the original DataFrame for continued chaining. It uses the `display` API from IPython to render the snapshot inline, with a default function that shows the DataFrame’s shape. The example highlights a practical debugging pattern for exploratory data analysis workflows.
This example visualizes a filtered subset of wine data, highlighting wines with high alcohol content (above 14), intense color (color intensity over 7), and a hue greater than 1. The display focuses on three attributes—alcohol, color intensity, and hue—sorted in descending order of alcohol. Built with Python using pandas, the code renames the `color_intensity` column to `ci`, creates a binary `color_filter` column via `np.where`, applies queries to filter rows, and finally selects and sorts the relevant columns. The data originates from a gist by adiamaan92, and the visualization is rendered as a tabular or plotted output from the resulting DataFrame.
This example visualizes the Wine Recognition dataset, showing the first few rows of the feature matrix as a tabular preview. The code loads the dataset using `load_wine()` from scikit-learn, then constructs a pandas DataFrame with `data.data` and `data.feature_names` as columns. The rendering displays the resulting `wine.head()` table, which shows the first five samples with their numerical attributes such as alcohol content and malic acid. The visualization relies on pandas' default DataFrame display formatting to present the data in a structured grid, making the dataset’s structure and feature values immediately visible.
This example visualizes a nested sequence of function calls as a branching tree layout, where each call—such as `went_up`, `fetch`, and `tumble_after`—appears as a node with its arguments as child branches. It shows the hierarchical flow of a story’s actions, with the root call `tumble_after` at the top and leaf nodes like `jack_jill` and `"hill"` at the bottom. The code uses `d3.forceSimulation` to position nodes and `d3.linkHorizontal` for curved edges, while the data is a hardcoded JavaScript object representing the call tree. Rendering is done with SVG paths and circles, styled via `d3.select` and `attr`.
This example visualizes the classic nursery rhyme "Jack and Jill" as a method-chaining sequence, where each action in the story corresponds to a link in a chain. It shows the narrative flow from going up the hill to tumbling after, with each step represented as a distinct visual node. The code uses D3.js’s `d3.forceSimulation` to lay out the chain nodes and links, while custom JavaScript functions animate the transitions between story stages. The rendering relies on SVG elements and D3’s `transition.attrTween` to smoothly move nodes along the chain. The data is hardcoded from the rhyme, not sourced externally.
A grouped bar chart tracks the expansion of service area across Indian states from 2002 to 2015. Each bar represents a state, with its width corresponding to the service-area value for the currently displayed year. The chart animates forward through the years, updating the bar widths and a large year label with transitions, using a short pause before looping back to the start. Color encodes each state. Built with D3 v3 and SVG, the bars grow and shrink as the timeline advances, providing a quick visual comparison of service-area changes over time.
The Monty Hall problem is presented as an interactive game where three grey circles represent doors, and one hides a winning prize. Users click a door, see a losing option revealed, then choose whether to stick or switch. The visualization tracks games played, wins, and winning percentage in live-updating statistics. Built with D3 v4, it uses SVG circles, data binding, and click event handlers to manage game state and render feedback dynamically.