Chapter 6: Data Analysis and Visualization#
What It Is#
Claude Code can read your data files — CSVs, Excel spreadsheets — and perform analysis, compute statistics, identify patterns, and create publication-quality charts and visualizations. It does this by writing and running Python scripts on your computer, using libraries like matplotlib, seaborn, and pandas. You never see or write the Python code. You describe the analysis you want, and Claude produces the results.
This is not a simplified “drag and drop chart builder.” This is a full-featured data analysis environment controlled through conversation. You can ask Claude to compute custom metrics, create multi-panel visualizations, perform statistical comparisons, classify data by categories, and produce charts that are ready for presentations, blog posts, or social media.
Why It Matters for Non-Technical Professionals#
Data is everywhere in modern professional work. Marketing teams have engagement metrics. Operators have financial data. Founders have market research. Product managers have user analytics. Researchers have survey responses.
The traditional workflow for turning this data into insight requires either Excel proficiency (which hits a wall for complex analyses and custom visualizations), specialized tools like Tableau or Power BI (which require training and subscriptions), or asking a data analyst to help (which creates dependencies and delays).
Claude Code eliminates the intermediary. You talk directly to your data. “What sectors generate the most engagement in my LinkedIn posts?” “Show me the trend in song duration over three decades.” “Compare the capital expenditure patterns of these seven companies.” The analysis happens in seconds, the visualization is produced in minutes, and you control every aspect of the output through conversation.
What You Need#
Pre-approved permissions:
- Bash(python3:*) — for running analysis scripts
- Bash(pip3 install:*) — for installing Python libraries on first use
Python libraries (Claude installs these automatically on first use):
- pandas — data manipulation
- matplotlib — chart creation
- seaborn — statistical visualization
- openpyxl — Excel file reading
No special plugins required, though the document-skills plugin is useful if you want to export results directly to Excel or PDF.
One built-in skill worth invoking by name: /dataviz. Claude Code now ships with a chart-and-dashboard design skill. Type /dataviz before asking for a chart — or just mention it in your prompt — and Claude designs against a proper visualization system: consistent colors, accessible contrast, clean layouts, instead of default library styling. For a chapter built on publication-quality charts, this is the cheapest upgrade available. It costs you one word.
The Workflows#
Workflow 1: Analyzing a CSV Without Opening Excel#
As a Claude prompt:
Read the CSV file at /Users/krishna/Desktop/Data/youtube-analytics.csv
Give me:
1. Total number of videos analyzed
2. Top 5 videos by views
3. Average views by content category
4. Engagement rate (likes + comments / views) distribution
5. Which content category I should make more of and which I should
make less of, based on the data
What Claude does: 1. Reads the CSV into a pandas DataFrame 2. Computes each requested metric 3. Presents results in formatted tables 4. Provides actionable recommendations based on the patterns
This basic workflow — load data, compute metrics, present insights — takes seconds and works with any structured dataset.
Workflow 2: Creating Custom Charts#
As a Claude prompt:
Using the data in /Users/krishna/Desktop/Data/music-discography.csv,
create a scatter plot showing:
- X axis: Year of release (1991 to 2024)
- Y axis: Song duration in minutes
- Add a 3-year moving average line in red
- Color the dots by decade (90s, 00s, 10s, 20s)
- Use a clean, modern design with a white background
- Title: "Song Duration Trends: 33 Years of a Music Director's Work"
- Save as a high-resolution PNG (300 DPI)
What Claude does: 1. Reads and processes the data 2. Computes the 3-year moving average 3. Creates a matplotlib chart with all specified design elements 4. Saves as a high-resolution PNG ready for social media or print
Real example from my usage: I analyzed thirty-three years of a legendary music director’s discography to test the hypothesis that song lengths have declined over time (as a proxy for attention spans). Claude created five different visualizations: scatter plots, violin plots by decade, bar charts of songs exceeding five and six minutes by era, and period-averaged trend lines. I iterated extensively on the design — colors, font readability, legend placement — until each chart was LinkedIn-ready. The analysis became a well-received LinkedIn post.
Workflow 3: Building Interactive HTML Visualizations#
For presentations or web sharing, static images are sometimes not enough. Claude can create interactive HTML visualizations that you can open in a browser.
As a Claude prompt:
Create an interactive HTML dashboard from the data in
/Users/krishna/Desktop/Data/company-financials.csv
Include:
- A line chart showing Capex-to-FCF ratio for each company over time
- Hover tooltips showing exact values
- A legend that lets you toggle companies on/off
- Clean, professional design suitable for a blog post
- Save as a single HTML file I can open in my browser
What Claude does: 1. Reads the data 2. Creates an HTML file using JavaScript charting libraries (often Chart.js or Plotly) 3. Implements interactivity (hover, toggle, zoom) 4. Saves as a self-contained HTML file
Real example: I created a Capex-to-FCF ratio line chart for major tech companies spanning multiple years. The interactive version let me hover over data points to see exact values, which was useful during presentations. For the social media version, Claude then created a static screenshot version with specific companies highlighted.
Workflow 4: LinkedIn Post Data Classification#
This is one of the most powerful non-obvious use cases for data analysis.
As a Claude prompt:
I have a CSV of my LinkedIn posts from 2024 at:
/Users/krishna/Desktop/Data/linkedin-posts-2024-classified.csv
The columns include: Date, Post Text, Sector Tag, and Content Type Tag.
The sector tags used are: Fintech, Consumer, SaaS, Deep Tech,
Healthcare, Climate, General, Personal.
The content type tags are: Original Insight, Data-Driven Analysis,
News Commentary, Personal Reflection, Curation, Announcement.
Now read this unclassified CSV of my 2025 posts at:
/Users/krishna/Desktop/Data/linkedin-posts-2025.csv
Using the 2024 classified data as training examples, classify each
2025 post with the same sector and content type taxonomy.
Save the results with two new columns added.
What Claude does: 1. Reads the 2024 classified data to learn the categorization patterns 2. Reads the 2025 unclassified data 3. Analyzes each post’s content against the learned taxonomy 4. Classifies each post with sector and content type tags 5. Saves the enhanced dataset
Results: In my experience, this achieves roughly 80% accuracy on first pass — good enough to be useful as a starting point, with manual corrections needed for the remaining 30%. For a dataset of 300+ posts, this saves hours of manual classification work.
Workflow 5: Survey Data Analysis#
As a Claude prompt:
Read the survey data at /Users/krishna/Desktop/Survey/responses.csv
This is a survey of 180+ professionals. The "Role" column indicates
their title (CEO, CTO, CMO, CPO, Other).
Give me:
1. Respondent count by role
2. For the question in column "AI_Excitement" (values:
"More Excited", "Same", "Less Excited"), show the distribution
both overall and broken down by role
3. For the question in column "AI_Investment" (values:
"Increasing", "Same", "Decreasing"), show the distribution
by role
4. Cross-tabulate excitement vs. investment direction
5. Identify the 3 most interesting patterns in the data
What Claude does: 1. Loads and cleans the data 2. Computes all requested breakdowns 3. Creates cross-tabulations 4. Identifies non-obvious patterns (correlations, outliers, segment differences) 5. Presents everything in formatted tables
Real example: I managed a survey analysis project with over 180 respondents across five executive personas. Claude computed breakdowns by persona, identified adoption patterns by business function, calculated budget allocations, and surfaced the key headline statistics (like “83% of respondents more excited about AI” and “48% freezing or reducing hiring”). These became the backbone of the final report.
Workflow 6: Time-Based and Comparative Analysis#
As a Claude prompt:
I want to estimate the total amount of time that the population of
a specific country spends daily across four major apps.
Here is what I know:
- App 1: 45 minutes average daily usage per user, 500M users
- App 2: 33 minutes average daily usage per user, 350M users
- App 3: 28 minutes average daily usage per user, 400M users
- App 4: 38 minutes average daily usage per user, 450M users
Calculate:
1. Total person-hours spent daily on each app
2. Total across all four apps
3. Express the total in "waking days" equivalent
(assume 16 waking hours per day)
4. Create a visualization showing the breakdown
All data comes from publicly available sources. Show your methodology.
What Claude does: 1. Computes the math for each app and the total 2. Converts to person-hours, person-days, and person-years 3. Creates a chart showing the proportional breakdown 4. Documents the methodology for transparency
Real example: I calculated that a country’s population collectively spends the equivalent of fifty waking days per year on just four apps. This computation involved multiple rounds of refinement — correcting the denominator (total smartphone users vs. total population), adjusting for different data sources, and refining the final metric. The resulting statistic became the hook for a LinkedIn post.
Workflow 7: Ad-Platform Analytics Without the Dashboard#
Ad dashboards are built for browsing, not for answering the question in your head. My team recently launched a video campaign with more than fifteen ad sets, and the dashboard could show me lead counts all day. The question I actually had — which creatives hold attention once someone presses play — meant clicking into each video, one by one.
So I skipped the dashboard. Claude Code was connected to the ad platform through its MCP, and I asked for the exact cut: view-through rates and average seconds watched for every video, in one table.
Picture a fictional cookware brand — call it EmberPan. The table shows the scrappy founder clip holding 38 percent of viewers past three seconds, while the expensive hero film loses everyone at two. That is a creative decision made in one glance.
A follow-up ask produced one more table: combined daily spend across all our ad accounts for the last ten days. No tab-hopping between accounts, no exports, no pivot table.
The setup is a one-time connect. Meta Ads has an official MCP, and most major ad platforms now have one — check Appendix B or search for your platform’s. Authenticate once, and every future question becomes a sentence.
Say to Claude:
Pull the view-through rates and average watch time for every video
in [campaign]. Which creatives hold attention past 3 seconds? Then
give me combined daily spend across all my ad accounts for the last
10 days as one table.
Pro Tips#
Tip 1: Iterate on chart design through conversation. Do not try to specify every design element in your first prompt. Start with the data and chart type, then refine: “Make the background white.” “Use these specific colors.” “Increase the font size.” “Move the legend to the top.” This iterative approach produces better results than trying to specify everything upfront.
Tip 2: Ask Claude to save charts at 300 DPI. Default chart resolution is often too low for social media or print. Always specify “save as PNG at 300 DPI” for high-resolution output.
Tip 3: When something looks off, ask why. “Why does the chart show a spike in Q3?” Claude can re-examine the data and explain anomalies.
Tip 4: For LinkedIn posts, ask Claude to optimize the chart dimensions. “Make this chart 1200x628 pixels for LinkedIn’s image preview format” ensures your chart looks good in the feed without cropping.
Tip 5: Save your data transformation steps. If you will re-run an analysis later (with updated data), ask Claude to save the analysis script: “Save the Python script you used so I can re-run this analysis next month.” This gives you a repeatable process.
Tip 6: Use the frontend-design plugin for interactive dashboards. For complex multi-chart dashboards, the frontend-design plugin produces dramatically better interactive HTML pages than raw Python charting. Prompt Claude to “create an interactive dashboard” after describing your data, and let the plugin guide the design.
Tip 7: Connect live data sources with MCPs for real-time analysis. The real power of Claude Code’s data analysis is not limited to static CSV files. With MCPs like Kite (Chapter 2), Claude can pull live portfolio data from your Zerodha account, calculate XIRR across your holdings, and generate performance charts — all without you exporting a single file. The MoSPI Stats MCP does the same for government economic data. The pattern is the same: MCP fetches the data, Claude analyzes it, Python generates the visualization. When your data source has an MCP, the entire export-import step disappears.
What Others Are Doing with Data Analysis#
The Claude Code community has surfaced some impressive data workflows worth knowing about:
Academic-grade analysis in 20 minutes. Cleaning Qualtrics survey data, running interaction analyses, and creating publication-quality tables and plots — all in under twenty minutes. The workflow: point Claude at the raw export, tell it to locate the relevant variables, simulate interaction effects, and produce formatted output. For researchers and analysts, this collapses what used to be a multi-hour process.
Literature review at scale via subagents. Using Claude Code to conduct literature reviews: download and skim 100 research papers, analyze them against specific criteria, and compile findings into a structured summary. The key technique is using parallel subagents — Claude dispatches multiple agents to process papers simultaneously, then synthesizes the results.
The “context as milk” principle. A contrarian insight from the community: treat your data context like milk — it spoils. For large datasets, do not load everything into Claude’s context at once. Instead, have Claude extract the specific columns or rows it needs, work with that subset, and return for more when needed. This produces better analysis because Claude can focus on what matters rather than being overwhelmed by the full dataset.