<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>business-science.io</title>
  <link href="https://www.business-science.io/atom.python-bloggers.xml" rel="self" />
  <link href="https://www.business-science.io/"/>
  <pubDate>2026-02-27 10:46:36</pubDate>
  <updated>2026-02-27T10:46:36-05:00</updated>
  <id>https://www.business-science.io</id>

  <author>
    <name>Business Science</name>
    <email>info@business-science.io</email>
  </author>
  
    <entry>
      <title>Create A Pandas Dataframe AI Agent With Generative AI, Python And OpenAI</title>
      <link href="https://www.business-science.io/genai-ml-tips/2025/12/08/data-analyst-ai-agent-genai-python.html" />
      <pubDate>2025-12-08 06:00:00</pubDate>
      <updated>2025-12-08T06:00:00-05:00</updated>
      <id>https://www.business-science.io/genai-ml-tips/2025/12/08/data-analyst-ai-agent-genai-python</id>
      <content type="html">&lt;p&gt;Hey guys, this is the first article in my &lt;a href=&quot;https://learn.business-science.io/free-ai-tips&quot;&gt;NEW GenAI / ML Tips Newsletter&lt;/a&gt;. Today, we’re diving into the world of &lt;strong&gt;Generative AI&lt;/strong&gt; and exploring how it can help companies automate common data science tasks. Specifically, we’ll learn how to &lt;strong&gt;create a Pandas dataframe agent&lt;/strong&gt; that can answer questions about your dataset using Python, Pandas, LangChain, and OpenAI’s API. Let’s get started!&lt;/p&gt;

&lt;h3 id=&quot;table-of-contents&quot;&gt;Table of Contents&lt;/h3&gt;

&lt;p&gt;Here’s what you’ll learn in this article:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Why Generative AI is Transforming Data Science&lt;/li&gt;
  &lt;li&gt;What is a Pandas Data Frame Agent?&lt;/li&gt;
  &lt;li&gt;Create a Pandas DataFrame Agent
    &lt;ul&gt;
      &lt;li&gt;Setting Up the Environment&lt;/li&gt;
      &lt;li&gt;Loading and Exploring the Dataset&lt;/li&gt;
      &lt;li&gt;Creating the Data Analysis Agent with LangChain&lt;/li&gt;
      &lt;li&gt;Interacting with the Agent&lt;/li&gt;
      &lt;li&gt;Visualizing the Results&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Before You Go Any Further:&lt;/strong&gt; &lt;strong&gt;&lt;a href=&quot;https://learn.business-science.io/free-ai-tips?el=website&quot;&gt;Join the Free GenAI/ML Tips Newsletter to get the Data and Code so you can follow along&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;this-is-what-you-are-making-today&quot;&gt;This is what you are making today&lt;/h1&gt;

&lt;p&gt;We’ll use this &lt;strong&gt;Generative AI Workflow&lt;/strong&gt; to combine data (from CSVs or SQL databases) with a Pandas Data Frame Agent that helps us produce common analytics outputs like visualizations and reports.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/AI001_pandas_data_agent.jpg&quot; alt=&quot;Make A Pandas Data Analysis Agent with Python and Generative AI&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;text-center date&quot;&gt;&lt;a href=&quot;https://learn.business-science.io/free-ai-tips?el=website&quot; target=&quot;_blank&quot;&gt;Get the Code (In the AI-Tip 001 Folder)&lt;/a&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;!--
# SPECIAL ANNOUNCEMENT: How To Become A &lt;u&gt;6-Figure Business Scientist&lt;/u&gt; (Even In A Recession) on August 30th

![Business Scientist](/assets/business-science-cube-2.jpg)

**What:** How To Become A 6-Figure Business Scientist (Even In A Recession)

**When:** Wednesday August 30th, 2pm EST

**How It Will Help You:** Data science in 2023 has changed. *The 10+ person data science team is out.* And the one-person Business Scientist is in. I&apos;ll show you how to become a 1-person data science team inside [my LIVE 6-figure business scientist masterclass](https://learn.business-science.io/registration-2-page?el=website). 

**Price:** Does **Free** sound good?

**How To Join:** [**👉 Register Here**](https://learn.business-science.io/registration-2-page?el=website)
--&gt;

&lt;!--
# SPECIAL ANNOUNCEMENT: ChatGPT for Data Scientists Workshop on December 11th

[Inside the workshop](https://learn.business-science.io/registration-chatgpt-2?el=website) I&apos;ll share how I built a Machine Learning Powered Production Shiny App with `ChatGPT` (extends this data analysis to an *insane* production app):

![ChatGPT for Data Scientists](/assets/lab_82_chatgpt_rcode.jpg)

**What:** ChatGPT for Data Scientists

**When:** Wednesday December 11th, 2pm EST

**How It Will Help You:** Whether you are new to data science or are an expert, ChatGPT is changing the game. There&apos;s a ton of hype. But how can ChatGPT actually help you become a better data scientist and help you stand out in your career? I&apos;ll show you inside [my free chatgpt for data scientists workshop](https://learn.business-science.io/registration-chatgpt-2?el=website). 

**Price:** Does **Free** sound good?

**How To Join:** [**👉 Register Here**](https://learn.business-science.io/registration-chatgpt-2?el=website)

--&gt;

&lt;h1 id=&quot;special-announcement-ai-for-data-scientists-workshop-on-december-18th&quot;&gt;SPECIAL ANNOUNCEMENT: AI for Data Scientists Workshop on December 18th&lt;/h1&gt;

&lt;p&gt;&lt;a href=&quot;https://learn.business-science.io/ai-register&quot;&gt;Inside the workshop&lt;/a&gt; I’ll share how I built a SQL-Writing Business Intelligence Agent with Generative AI:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/how_to_create_a_business_intelligence_ai_copilot.jpg&quot; alt=&quot;Generative AI for Data Scientists&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What:&lt;/strong&gt; GenAI for Data Scientists&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When:&lt;/strong&gt; Wednesday December 18th, 2pm EST&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How It Will Help You:&lt;/strong&gt; Whether you are new to data science or are an expert, Generative AI is changing the game. There’s a ton of hype. But how can Generative AI actually help you become a better data scientist and help you stand out in your career? I’ll show you inside &lt;a href=&quot;https://learn.business-science.io/ai-register&quot;&gt;my free Generative AI for Data Scientists workshop&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Price:&lt;/strong&gt; Does &lt;strong&gt;Free&lt;/strong&gt; sound good?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How To Join:&lt;/strong&gt; &lt;a href=&quot;https://learn.business-science.io/ai-register&quot;&gt;&lt;strong&gt;👉 Register Here&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;h1 id=&quot;genaiml-tips-weekly&quot;&gt;GenAI/ML-Tips Weekly&lt;/h1&gt;

&lt;p&gt;This article is part of GenAI/ML Tips Weekly, a &lt;a href=&quot;https://learn.business-science.io/free-ai-tips?el=website&quot; target=&quot;_blank&quot;&gt;weekly video tutorial&lt;/a&gt; that shows you step-by-step how to do common Data Science and Generative AI coding tasks. Pretty cool, right?&lt;/p&gt;

&lt;p&gt;Here is the link to get set up. 👇&lt;/p&gt;

&lt;ul&gt; 
    &lt;li&gt;&lt;a href=&quot;https://learn.business-science.io/free-ai-tips?el=website&quot; target=&quot;_blank&quot;&gt;Sign up for our GenAI/ML Tips Newsletter and get the code.&lt;/a&gt;&lt;/li&gt; 
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;/assets/AI001_get_the_code.jpg&quot; alt=&quot;Get the code&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;text-center date&quot;&gt;&lt;a href=&quot;https://learn.business-science.io/free-ai-tips?el=website&quot; target=&quot;_blank&quot;&gt;Get the Code (In the GenAI/ML Tip 001 Folder)&lt;/a&gt;&lt;/p&gt;

&lt;h1 id=&quot;this-tutorial-is-available-in-video-9-minutes&quot;&gt;This Tutorial is Available in Video (9-minutes)&lt;/h1&gt;

&lt;p&gt;I have a &lt;strong&gt;9-minute video&lt;/strong&gt; that walks you through setting up the Pandas Data Frame Agent and running data analysis with it.  👇&lt;/p&gt;

&lt;iframe width=&quot;100%&quot; height=&quot;450&quot; src=&quot;https://www.youtube.com/embed/2LDyRnUgLos&quot; title=&quot;YouTube video player&quot; frameborder=&quot;1&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;

&lt;h1 id=&quot;why-generative-ai-is-transforming-data-science&quot;&gt;Why Generative AI is Transforming Data Science&lt;/h1&gt;

&lt;p&gt;Generative AI, powered by models like OpenAI’s GPT series, is reshaping the data science landscape. These models can understand and generate human-like text, making it possible to interact with data in more intuitive ways. By integrating Generative AI into data science, you can:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Automate Data Insights:&lt;/strong&gt; Quickly generate summaries and insights from complex datasets.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Enhance Decision Making:&lt;/strong&gt; Obtain answers to specific questions without manually sifting through data.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Improve Accessibility:&lt;/strong&gt; Make data science more accessible to non-technical stakeholders.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Creating a &lt;strong&gt;Pandas dataframe agent&lt;/strong&gt; combines the power of AI with data science, enabling you to unlock new possibilities in data exploration and interpretation from Natural Language.&lt;/p&gt;

&lt;h1 id=&quot;what-is-a-pandas-data-frame-agent&quot;&gt;What is a Pandas Data Frame Agent?&lt;/h1&gt;

&lt;p&gt;A &lt;strong&gt;Pandas Data Frame Agent&lt;/strong&gt; automates common Pandas operations from Natural Language inputs.&lt;/p&gt;

&lt;p&gt;It can be used to perform:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;GroupBy + Aggregate&lt;/li&gt;
  &lt;li&gt;Math calculations (that normal LLMs struggle with)&lt;/li&gt;
  &lt;li&gt;Filters&lt;/li&gt;
  &lt;li&gt;Pivots&lt;/li&gt;
  &lt;li&gt;Window calculations&lt;/li&gt;
  &lt;li&gt;Resampling (Time Series)&lt;/li&gt;
  &lt;li&gt;Binning&lt;/li&gt;
  &lt;li&gt;Log Transformations&lt;/li&gt;
  &lt;li&gt;Summary Statistics (Mean, Median, IQR, Min/Max, Count (frequency), etc)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All from Natural Language prompts.&lt;/p&gt;

&lt;h1 id=&quot;make-a-pandas-data-frame-agent&quot;&gt;Make A Pandas Data Frame Agent&lt;/h1&gt;

&lt;p&gt;Let’s walk through the steps to create a Pandas data frame agent that can answer questions about a dataset using Python, OpenAI’s API, Pandas, and LangChain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Quick Reminder:&lt;/strong&gt; You can get all of the code and datasets shown in a Python Script and Jupyter Notebook when you &lt;a href=&quot;https://learn.business-science.io/free-ai-tips?el=website&quot;&gt;join my GenAI/ML Tips Newsletter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Location:&lt;/strong&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/001_pandas_dataframe_agent&lt;/code&gt;&lt;/p&gt;

&lt;h2 id=&quot;step-1-setting-up-the-python-environment&quot;&gt;Step 1: Setting Up the Python Environment&lt;/h2&gt;

&lt;p&gt;First, you’ll need to set up your Python environment and install the required libraries.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;pip&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;openai&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;langchain&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;langchain_openai&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;langchain_experimental&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pandas&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plotly&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pyyaml&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Next, import the libraries.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/AI001_libraries_1.jpg&quot; alt=&quot;Libraries&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Then run this to access our utility function, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;parse_json_to_dataframe()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/AI001_utility_function.jpg&quot; alt=&quot;Utility Function&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The last part is to set up your OpenAI API Key. Make sure to get an API Key from OpenAI’s API website.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/AI001_openai_api_key.jpg&quot; alt=&quot;OpenAI API Key&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Replace ‘credentials.yml’ with the path to your YAML file containing the OpenAI API key or set the ‘OPENAI_API_KEY’ environment variable directly.&lt;/p&gt;

&lt;h2 id=&quot;step-2-loading-and-exploring-the-dataset&quot;&gt;Step 2: Loading and Exploring the Dataset&lt;/h2&gt;

&lt;p&gt;Load your dataset into a Pandas DataFrame. For this tutorial, we’ll use a sample customer data CSV file. But you could easily use any data that you can get into a Pandas Data Frame:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;SQL Database&lt;/li&gt;
  &lt;li&gt;CSV&lt;/li&gt;
  &lt;li&gt;Excel File&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Run this code to load the customer dataset:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/AI001_customer_dataset.jpg&quot; alt=&quot;Load The Customer Dataset&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This dataset contains customer information, including sales and geography data.&lt;/p&gt;

&lt;h2 id=&quot;step-3-create-the-pandas-data-analysis-agent-with-langchain&quot;&gt;Step 3: Create the Pandas Data Analysis Agent with LangChain&lt;/h2&gt;

&lt;p&gt;Initialize the language model and create the Pandas data analysis agent using LangChain.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/AI001_create_pandas_data_frame_agent.jpg&quot; alt=&quot;Create The Pandas Data Frame Agent&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This is what’s happening:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ChatOpenAI&lt;/code&gt;: Initializes the OpenAI language model.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;create_pandas_dataframe_agent&lt;/code&gt;: Creates an agent that can interact with the Pandas DataFrame.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;agent_type&lt;/code&gt;: Specifies the type of agent (using OpenAI functions).&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;suffix&lt;/code&gt;: Instructs the agent to return results in JSON format for easy parsing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Pro-Tip:&lt;/strong&gt; The secret sauce is to use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;suffix&lt;/code&gt; parameter to specify the output format. Under the hood, this appends the agent’s default prompt template with additional information that describes how to return the information.&lt;/p&gt;

&lt;h2 id=&quot;step-4-interacting-with-the-pandas-data-frame-agent&quot;&gt;Step 4: Interacting with the Pandas Data Frame Agent&lt;/h2&gt;

&lt;p&gt;Now, you can ask the agent questions about your data. Try running this code with a Natural Language analysis question:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;“What are the total sales by geography?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;img src=&quot;/assets/AI001_invoke_the_agent.jpg&quot; alt=&quot;Invoke the agent&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The agent processes the query and returns a response.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/AI001_process_query.jpg&quot; alt=&quot;Process Query&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This is where Post Processing comes into play. Remember when I added the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;suffix&lt;/code&gt; parameter to return JSON. The Agent actually burries the JSON in a string.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/AI001_json_string.jpg&quot; alt=&quot;JSON String&quot; /&gt;&lt;/p&gt;

&lt;p&gt;That’s OK, because I have created a handy little parsing tool that extracts the JSON from the string and converts it to a Pandas Data Frame for us.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/AI001_convert_json_to_pandas.jpg&quot; alt=&quot;Convert JSON To Pandas&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;step-5-visualizing-the-results&quot;&gt;Step 5: Visualizing the Results&lt;/h2&gt;

&lt;p&gt;With a pandas data frame we can then report the results. I’ll do this manually with Plotly, but a great challenge is to extend the code to create an AI agent that makes the visualization code and executes it automatically.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/AI001_visualization.jpg&quot; alt=&quot;Data Visualization&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This visualization provides a clear view of sales distribution across different geographical regions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Quick Reminder:&lt;/strong&gt; You can get all of the code and datasets shown in a Python Script and Jupyter Notebook when you &lt;a href=&quot;https://learn.business-science.io/free-ai-tips?el=website&quot;&gt;join my GenAI/ML Tips Newsletter&lt;/a&gt;.&lt;/p&gt;

&lt;h1 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h1&gt;

&lt;p&gt;By integrating Generative AI with data science, you’ve created a powerful tool that can interact with your data in natural language. This Pandas data analysis agent simplifies the process of extracting insights and can help non-technical stakeholders automate common data manipulations to help them make data-driven decisions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But there’s so much more to learn in Generative AI and data science.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you’re excited to become a Generative AI Data Scientist with Python, then keep reading…&lt;/p&gt;

&lt;h1 id=&quot;become-a-generative-ai-data-scientist&quot;&gt;Become A Generative AI Data Scientist&lt;/h1&gt;

&lt;p&gt;The future of data science is AI / ML.&lt;/p&gt;

&lt;p&gt;I’ve helped 6,107+ students learn data science and now I’m helping them become Generative AI Data Scientists, skilled in combining Generative AI / ML. With this system they have:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Landed Promotions to Manager of AI/ML Teams ($200,000+ Role)&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Made Proof-Of-Concepts for Clients ($25,000+ Consulting Projects)&lt;/strong&gt;&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Grew their data science skills with Generative AI (Career Growth)&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;heres-the-system-they-are-taking-to-become-generative-ai-data-scientists&quot;&gt;Here’s the system they are taking to become Generative AI Data Scientists:&lt;/h1&gt;

&lt;p&gt;&lt;img src=&quot;/assets/generative_ai_bootcamp.jpg&quot; alt=&quot;Generative AI Bootcamp&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This is a &lt;strong&gt;Live 8-Week Generative AI Bootcamp&lt;/strong&gt; for Data Scientists that covers:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Week 1:&lt;/strong&gt; Live Kickoff Clinic + Local LLM Training + AI Fast Track&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Week 2:&lt;/strong&gt; Retrieval Augmented Generation (RAG)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Week 3:&lt;/strong&gt; Business Intelligence AI Copilot (SQL + Pandas Tools)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Week 4:&lt;/strong&gt; Customer Analytics Team (Multi-Agent Workflows)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Week 5:&lt;/strong&gt; Time Series Forecasting Team (Multi-Agent Machine Learning Workflows)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Week 6:&lt;/strong&gt; LLM Model Deployment AWS Bedrock&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Week 7:&lt;/strong&gt; Fine-Tuning LLM Models AWS Bedrock&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Week 8:&lt;/strong&gt; AI App Deployment With AWS Cloud&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p style=&quot;font-size: 36px;text-align: center;&quot;&gt;
&lt;a href=&quot;https://learn.business-science.io/generative-ai-bootcamp-enroll&quot;&gt;
&lt;strong&gt;Enroll In The Next Cohort Here&lt;/strong&gt;&lt;br /&gt;&lt;small style=&quot;font-size:24px;&quot;&gt;(And Become A Generative AI Data Scientist in 2026)&lt;/small&gt;
&lt;/a&gt;
&lt;/p&gt;

</content>
      
      <category>Python-Bloggers</category>
      
      <category>Learn-Python</category>
      
      <category>Python</category>
      
      <category>Pandas</category>
      
      <category>OpenAI</category>
      
      <category>LangChain</category>
      
      
      <category>GenAI-ML-Tips</category>
      
    </entry>
  
    <entry>
      <title>3 Ways to Read Multiple CSV Files: For-Loop, Map, List Comprehension</title>
      <link href="https://www.business-science.io/python/2021/09/21/python-read-csv.html" />
      <pubDate>2021-09-21 02:01:00</pubDate>
      <updated>2021-09-21T02:01:00-04:00</updated>
      <id>https://www.business-science.io/python/2021/09/21/python-read-csv</id>
      <content type="html">&lt;p&gt;Reading many CSV files is a common task for a data scientist. In this free tutorial, we show you 3 ways to streamline reading CSV files in Python. &lt;strong&gt;You’ll read and combine 15 CSV Files using the top 3 methods for iteration.&lt;/strong&gt;&lt;/p&gt;

&lt;h2 id=&quot;python-tips-weekly&quot;&gt;Python Tips Weekly&lt;/h2&gt;

&lt;p&gt;This article is part of Python-Tips Weekly, a &lt;a href=&quot;https://learn.business-science.io/python-tips-newsletter&quot; target=&quot;_blank&quot;&gt;bi-weekly video tutorial&lt;/a&gt; that shows you step-by-step how to do common Python coding tasks.&lt;/p&gt;

&lt;p&gt;Here are the links to get set up. 👇&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;&lt;a href=&quot;https://learn.business-science.io/python-tips-newsletter&quot; target=&quot;_blank&quot;&gt;Get the Code&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;https://youtu.be/TN_Cvyq_rxE&quot; target=&quot;_blank&quot;&gt;YouTube Tutorial&lt;/a&gt;&lt;/li&gt; 
&lt;/ul&gt;

&lt;h1 id=&quot;video-tutorialfollow-along-with-our-full-youtube-video-tutorial&quot;&gt;Video Tutorial&lt;br /&gt;&lt;small&gt;Follow along with our Full YouTube Video Tutorial.&lt;/small&gt;&lt;/h1&gt;

&lt;p&gt;This 5-minute video covers reading multiple CSV in python.&lt;/p&gt;

&lt;figure class=&quot;text-center&quot;&gt;
    &lt;a href=&quot;https://youtu.be/TN_Cvyq_rxE&quot; target=&quot;_blank&quot;&gt;
    &lt;img src=&quot;/assets/2021-09-22-python-csv/006_read_csv_thumb.jpg&quot; style=&quot;max-width:100%;&quot; /&gt; &lt;/a&gt;
  &lt;figcaption&gt;(Click image to play tutorial)&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h1 id=&quot;read-15-csv-files-tutorial&quot;&gt;Read 15 CSV Files [Tutorial]&lt;/h1&gt;

&lt;p&gt;This FREE tutorial showcases the awesome power of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;python&lt;/code&gt; for reading CSV files. We’ll read &lt;strong&gt;15 CSV files&lt;/strong&gt; in this tutorial.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/2021-09-22-python-csv/00-csv-files.jpg&quot; style=&quot;max-width:100%;margin-bottom:5px;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;before-we-get-started-get-the-python-cheat-sheet&quot;&gt;Before we get started, get the Python Cheat Sheet&lt;/h2&gt;

&lt;p&gt;The Python Ecosystem is LARGE. To help, I’ve curated many of the &lt;strong&gt;80/20 Python Packages&lt;/strong&gt;, those I use most frequently to get results. Simply &lt;a href=&quot;https://www.business-science.io/python-cheatsheet.html&quot;&gt;Download the Ultimate Python Cheat Sheet&lt;/a&gt; to access the entire Python Ecosystem at your fingertips via hyperlinked documentation and cheat sheets.&lt;/p&gt;

&lt;figure class=&quot;text-center&quot;&gt;
&lt;a href=&quot;https://www.business-science.io/python-cheatsheet.html&quot; target=&quot;_blank&quot;&gt; 
  &lt;img src=&quot;/assets/2021-07-06-sklearn/ultimate_python_cheatsheet.jpg&quot; style=&quot;max-width:100%;&quot; /&gt;
  &lt;figcaption&gt;(Click image to download)&lt;/figcaption&gt;
&lt;/a&gt;
&lt;/figure&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;Onto the tutorial.&lt;/p&gt;

&lt;h2 id=&quot;project-setup&quot;&gt;Project Setup&lt;/h2&gt;

&lt;p&gt;First, load the libraries. We’ll import &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pandas&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;glob&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Pandas&lt;/code&gt;: The main data wrangling library in Python&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;glob&lt;/code&gt;: A library for locating file paths using text searching (regular expressions)&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Second, use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;glob&lt;/code&gt; to extract a list of the file paths for each of the 15 CSV files we need to read in.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/2021-09-22-python-csv/00-libraries.jpg&quot; alt=&quot;Libraries&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;text-center date&quot;&gt; 
  &lt;a href=&quot;https://learn.business-science.io/python-tips-newsletter&quot; target=&quot;_blank&quot;&gt;Get the code.&lt;/a&gt;
&lt;/p&gt;

&lt;h2 id=&quot;method-1-for-loop&quot;&gt;Method 1: For-Loop&lt;/h2&gt;

&lt;p&gt;The most common way to repetitively read files is with a for-loop. It’s a great way for beginners but it’s not the most concise. We’ll show this way first.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/2021-09-22-python-csv/01-csv-for-loop.jpg&quot; alt=&quot;Python For-Loop for Reading CSV Files&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;text-center date&quot;&gt; 
  &lt;a href=&quot;https://learn.business-science.io/python-tips-newsletter&quot; target=&quot;_blank&quot;&gt;Get the code.&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;We can see that this involves 3-steps:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Instantiating an Empty List:&lt;/strong&gt; We do this to store our results as we make them in the for-loop.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;For-Each filename, read and append:&lt;/strong&gt; We read using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pd.read_csv()&lt;/code&gt;, which returns a data frame for each path. Then we append each data frame to our list.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Combine each Data Frame:&lt;/strong&gt; We use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pd.concat()&lt;/code&gt; to combine the list of data frames into one big data frame.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;PRO-TIP:&lt;/strong&gt; Combining data frames in lists is a common strategy. Don’t forget to use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;axis=0&lt;/code&gt; to specify row-wise combining.&lt;/p&gt;

&lt;h2 id=&quot;method-2-using-map&quot;&gt;Method 2: Using Map&lt;/h2&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;map()&lt;/code&gt; function is a more concise way to iterate. The advantage is that we don’t have to instantiate a list. However, it can be more confusing to beginners.&lt;/p&gt;

&lt;h3 id=&quot;how-it-works&quot;&gt;How it works:&lt;/h3&gt;

&lt;p&gt;Map takes in two general arguments:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;func:&lt;/strong&gt; A function to iteratively apply&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;*iterables&lt;/strong&gt;: One or more iterables that are supplied to the function in order of the functions arguments.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;/assets/2021-09-22-python-csv/02-how-map-works.jpg&quot; alt=&quot;How Map Works (Python)&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;text-center date&quot;&gt; 
  &lt;a href=&quot;https://learn.business-science.io/python-tips-newsletter&quot; target=&quot;_blank&quot;&gt;Get the code.&lt;/a&gt;
&lt;/p&gt;

&lt;h2 id=&quot;lets-use-it&quot;&gt;Let’s use it.&lt;/h2&gt;

&lt;p&gt;Ok, so let’s try &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;map()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/2021-09-22-python-csv/02-using-map.jpg&quot; alt=&quot;Python Map for Reading CSV Files&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;text-center date&quot;&gt; 
  &lt;a href=&quot;https://learn.business-science.io/python-tips-newsletter&quot; target=&quot;_blank&quot;&gt;Get the code.&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;We use 3-steps:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Make a Lambda Function:&lt;/strong&gt; This is an anonymous function that we create on the fly with the first argument that will accept our iterable (each filename in our list of csv file paths).&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Supply the iterable:&lt;/strong&gt; In this case, we provide our list of csv files. The map function will then iteratively supply each element to the function in succession.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Convert to List:&lt;/strong&gt; The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;map()&lt;/code&gt; function returns a map object. We can then convert this to a list using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;list()&lt;/code&gt; function.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;PRO-TIP:&lt;/strong&gt; Beginners can be confused by the “map object” that is returned. Just simply use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;list()&lt;/code&gt; function to extract the results of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;map()&lt;/code&gt; in a list structure.&lt;/p&gt;

&lt;h2 id=&quot;method-3-list-comprehension&quot;&gt;Method 3: List Comprehension&lt;/h2&gt;

&lt;p&gt;Because we are returning a list, even easier than &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;map()&lt;/code&gt;, we can use a &lt;strong&gt;List Comprehension.&lt;/strong&gt; A list comprehension is a streamlined way of making a for-loop that returns a list. Here’s how it works.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/2021-09-22-python-csv/03-list-comprehension.jpg&quot; alt=&quot;Python List Comprehension for Reading CSV Files&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;text-center date&quot;&gt; 
  &lt;a href=&quot;https://learn.business-science.io/python-tips-newsletter&quot; target=&quot;_blank&quot;&gt;Get the code.&lt;/a&gt;
&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Do this&lt;/strong&gt;: Add the function that you want to iterate. The parameter must match your looping variable name (next).&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;For each of these&lt;/strong&gt;: This is your looping variable name that you create inside of the list comprehension. Each of these are elements that will get passed to your function.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;In this:&lt;/strong&gt; This is your iterable. The list containing each of our file paths.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&quot;summary&quot;&gt;Summary&lt;/h1&gt;

&lt;p&gt;There you have it. You now know how to read CSV files using 3 methods:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;For-Loops&lt;/li&gt;
  &lt;li&gt;Map&lt;/li&gt;
  &lt;li&gt;List Comprehension&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;But there’s a lot more to learning data science. And if you’re like me, you’re interested in a fast track system that will advance you &lt;strong&gt;without wasting time&lt;/strong&gt; on information you don’t need.&lt;/p&gt;

&lt;p&gt;The solution is my course, Data Science Automation with Python&lt;/p&gt;

&lt;h1 id=&quot;data-science-automation-with-python-course&quot;&gt;Data Science Automation with Python Course&lt;/h1&gt;

&lt;p&gt;Tired of struggling to learn data science? Getting stuck in a sea of neverending resources? &lt;strong&gt;Eliminate the confusion and speed up your learning in the process.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Businesses are transitioning manual processes to Python for automation. We teach you skills that organizations need right now.&lt;/p&gt;

&lt;p&gt;Learn how in our new course, &lt;a href=&quot;https://university.business-science.io/p/python-for-data-science-automation-ds4b-101p&quot;&gt;Python for Data Science Automation&lt;/a&gt;. Perform an end-to-end business forecast automation using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pandas&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sktime&lt;/code&gt;, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;papermill&lt;/code&gt;, and learn Python in the process.&lt;/p&gt;

&lt;p&gt;&lt;span data-sumome-listbuilder-embed-id=&quot;54e6313db4cf24a7bf10be451ee765d85561e812a98e3acc20e3d4d63a65367d&quot;&gt;&lt;/span&gt;&lt;/p&gt;

&lt;!-- This is markdown code. It wont look formatted in your browser, 
    but will be fine when published. to the website --&gt;

&lt;!-- 
&lt;span data-sumome-listbuilder-embed-id=&quot;9cdb3104db3972bf15bfcdd21d0ae1d67082ed31c22aef5a700b86b9b2cdf5fd&quot;&gt;&lt;/span&gt;
 --&gt;

&lt;!-- 
&lt;br&gt;

&lt;div style=&quot;background-color:whitesmoke; padding:14px;&quot;&gt;
    &lt;p&gt;
    &lt;h2&gt;👇 Top R-Tips Tutorials you might like:&lt;/h2&gt;
    &lt;ol&gt;
        &lt;li&gt;&lt;a href=&quot;/code-tools/2021/05/04/mmtable2.html&quot;&gt;mmtable2: ggplot2 for tables&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;/r/2021/07/22/ggdist-raincloud-plots.html&quot;&gt;ggdist: Make a Raincloud Plot to Visualize Distribution in ggplot2&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;/code-tools/2021/05/18/marginal_distributions.html&quot;&gt;ggside: Plot linear regression with marginal distributions&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;/code-tools/2021/05/18/dataeditr.html&quot;&gt;DataEditR: Interactive Data Editing in R&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;/code-tools/2020/10/07/automate-excel.html&quot;&gt;openxlsx: How to Automate Excel in R&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;/code-tools/2020/09/22/automate-powerpoint.html&quot;&gt;officer: How to Automate PowerPoint in R&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;/code-tools/2021/03/02/use-dataexplorer-for-EDA.html&quot;&gt;DataExplorer: Fast EDA in R&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;/code-tools/2021/03/23/ggplot-code-with-tableau-esquisse.html&quot;&gt;esquisse: Interactive ggplot2 builder&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;/code-tools/2021/05/25/gghalves.html&quot;&gt;gghalves: Half-plots with ggplot2&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;/code-tools/2020/10/21/automate-pdf-with-r.html&quot;&gt;rmarkdown: How to Automate PDF Reporting&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;/code-tools/2021/05/11/patchwork.html&quot;&gt;patchwork: How to combine multiple ggplots&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;/code-tools/2020/12/08/geographic-map-visualization.html&quot;&gt;Geospatial Map Visualizations in R&lt;/a&gt;&lt;/li&gt;
    &lt;/ol&gt;
    &lt;/p&gt;
    &lt;p&gt;
        Want these tips every week? &lt;a href=&quot;https://learn.business-science.io/r-tips-newsletter&quot;&gt;Join R-Tips Weekly.&lt;/a&gt;
    &lt;/p&gt;
&lt;/div&gt;

&lt;br&gt;
 --&gt;

</content>
      
      <category>Learn-Python</category>
      
      <category>Python-Bloggers</category>
      
      <category>For-Loop</category>
      
      
      <category>python</category>
      
    </entry>
  
    <entry>
      <title>SweetViz: Automated Exploratory Data Analysis (EDA) in Python</title>
      <link href="https://www.business-science.io/python/2021/08/03/sweetviz-eda.html" />
      <pubDate>2021-08-03 04:01:00</pubDate>
      <updated>2021-08-03T04:01:00-04:00</updated>
      <id>https://www.business-science.io/python/2021/08/03/sweetviz-eda</id>
      <content type="html">&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SweetViz&lt;/code&gt; is a Python library that makes exploratory data analysis (EDA) fast and effective. Learn how to investigate feature relationships using correlation and associations in the &lt;strong&gt;automated SweetViz report.&lt;/strong&gt;&lt;/p&gt;

&lt;h2 id=&quot;python-tips-weekly&quot;&gt;Python Tips Weekly&lt;/h2&gt;

&lt;p&gt;This article is part of Python-Tips Weekly, a &lt;a href=&quot;https://learn.business-science.io/python-tips-newsletter&quot; target=&quot;_blank&quot;&gt;bi-weekly video tutorial&lt;/a&gt; that shows you step-by-step how to do common Python coding tasks.&lt;/p&gt;

&lt;p&gt;Here are the links to get set up. 👇&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;&lt;a href=&quot;https://learn.business-science.io/python-tips-newsletter&quot; target=&quot;_blank&quot;&gt;Get the Code&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;https://youtu.be/CCy0JAB_fbo&quot; target=&quot;_blank&quot;&gt;YouTube Tutorial&lt;/a&gt;&lt;/li&gt; 
&lt;/ul&gt;

&lt;h1 id=&quot;video-tutorialfollow-along-with-our-full-youtube-video-tutorial&quot;&gt;Video Tutorial&lt;br /&gt;&lt;small&gt;Follow along with our Full YouTube Video Tutorial.&lt;/small&gt;&lt;/h1&gt;

&lt;p&gt;Learn how to use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SweetViz&lt;/code&gt; to make and investigate an automated EDA Report.&lt;/p&gt;

&lt;figure class=&quot;text-center&quot;&gt;
    &lt;a href=&quot;https://youtu.be/CCy0JAB_fbo&quot; target=&quot;_blank&quot;&gt;
    &lt;img src=&quot;/assets/2021-08-03-sweetviz/005_sweetviz_thumb.jpg&quot; style=&quot;max-width:100%;&quot; /&gt; &lt;/a&gt;
  &lt;figcaption&gt;(Click image to play tutorial)&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h1 id=&quot;before-we-get-started-get-the-python-cheat-sheet&quot;&gt;Before we get started, get the Python Cheat Sheet&lt;/h1&gt;

&lt;p&gt;The Python Ecosystem is LARGE. To help, I’ve curated many of the &lt;strong&gt;80/20 Python Packages&lt;/strong&gt;, those I use most frequently to get results. Simply &lt;a href=&quot;https://www.business-science.io/python-cheatsheet.html&quot;&gt;Download the Ultimate Python Cheat Sheet&lt;/a&gt; to access the entire Python Ecosystem at your fingertips via hyperlinked documentation and cheat sheets.&lt;/p&gt;

&lt;figure class=&quot;text-center&quot;&gt;
&lt;a href=&quot;https://www.business-science.io/python-cheatsheet.html&quot; target=&quot;_blank&quot;&gt; 
  &lt;img src=&quot;/assets/2021-07-06-sklearn/ultimate_python_cheatsheet.jpg&quot; style=&quot;max-width:100%;&quot; /&gt;
  &lt;figcaption&gt;(Click image to download)&lt;/figcaption&gt;
&lt;/a&gt;
&lt;/figure&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;Onto the tutorial.&lt;/p&gt;

&lt;h1 id=&quot;sweetviz-automating-eda&quot;&gt;SweetViz: Automating EDA&lt;/h1&gt;

&lt;p&gt;Let’s check out how to &lt;strong&gt;automate&lt;/strong&gt; an exploratory data analysis report with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SweetViz&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/2021-08-03-sweetviz/sweetviz_report.jpg&quot; alt=&quot;SweetViz EDA Report&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;text-center date&quot;&gt; 
  &lt;a href=&quot;https://learn.business-science.io/python-tips-newsletter&quot; target=&quot;_blank&quot;&gt;Get the code.&lt;/a&gt;
&lt;/p&gt;

&lt;h2 id=&quot;step-1-load-libraries-and-data&quot;&gt;Step 1: Load Libraries and Data&lt;/h2&gt;

&lt;p&gt;First, let’s load the libraries and data. From the libraries, we’ll import &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pandas&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sweetviz&lt;/code&gt; and my favorite plotting library, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plotnine&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/2021-08-03-sweetviz/00_libraries.jpg&quot; alt=&quot;Libraries&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;text-center date&quot;&gt; 
  &lt;a href=&quot;https://learn.business-science.io/python-tips-newsletter&quot; target=&quot;_blank&quot;&gt;Get the code.&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mpg_df&lt;/code&gt; data set contains information on fuel efficiency (mpg) along with important vehicle attributes for 398 vehicles.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/2021-08-03-sweetviz/00_data.jpg&quot; alt=&quot;MPG Data&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;text-center date&quot;&gt; 
  &lt;a href=&quot;https://learn.business-science.io/python-tips-newsletter&quot; target=&quot;_blank&quot;&gt;Get the code.&lt;/a&gt;
&lt;/p&gt;

&lt;h2 id=&quot;step-2-make-the-sweetviz-eda-report-in-2-lines-of-code&quot;&gt;Step 2: Make the SweetViz EDA Report in 2 Lines of Code&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;Goal: Understand the relationship between Fuel Economy (MPG) and features in this dataset&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We can assess the relationship between vehicle fuel economy and the explanatory features using the sweetviz report. SweetViz &lt;strong&gt;automates&lt;/strong&gt; the process of creating the EDA report in two lines of code.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/2021-08-03-sweetviz/01_sweetviz_report_code.jpg&quot; alt=&quot;SweetViz Report Code&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;text-center date&quot;&gt; 
  &lt;a href=&quot;https://learn.business-science.io/python-tips-newsletter&quot; target=&quot;_blank&quot;&gt;Get the code.&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;This creates the SweetViz EDA Report.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/2021-08-03-sweetviz/sweetviz_report.jpg&quot; alt=&quot;SweetViz EDA Report&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;step-3-investigate-the-feature-correlation-associations&quot;&gt;Step 3: Investigate the Feature Correlation (Associations)&lt;/h2&gt;

&lt;p&gt;We can investigate the feature associations / correlations and see that number of cylinders (engine size), displacement (engine volume), horsepower, weight have a relationship to vehicle fuel efficiency.&lt;/p&gt;

&lt;h3 id=&quot;3a-high-level-correlations-associations&quot;&gt;3A: High-Level Correlations (Associations)&lt;/h3&gt;

&lt;p&gt;We start with an overall view of the high-level relationships.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/2021-08-03-sweetviz/03_correlation.jpg&quot; alt=&quot;SweetViz Correlation&quot; /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;The squares are categorical features.&lt;/strong&gt; Their relationships range from 0 to 1 indicating associative strength only. We need to need to inspect tabs for categories like cylinder, which has a high associative strength to determine its effect on MPG.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;The circles are numeric features.&lt;/strong&gt; Their relationships range from -1 to 1 following a Pearson Correlation. We can see positive and negative relationships indicated by the sign (+/-) and strength of relationship (closer to +/-1 is strong, closer to zero is weak).&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;3b-distribution-analysis-individual-features&quot;&gt;3B: Distribution Analysis: Individual Features&lt;/h3&gt;

&lt;p&gt;We can take a step further and investigate individual features to see how each relate to the target by &lt;strong&gt;comparing their distributions&lt;/strong&gt;.&lt;/p&gt;

&lt;h4 id=&quot;feature-tabs&quot;&gt;Feature Tabs&lt;/h4&gt;

&lt;p&gt;For example, we can investigate “cylinders” to see how the distributions co-vary. Just click on the “cylinders” tab.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/2021-08-03-sweetviz/03_cylinders_tab.jpg&quot; alt=&quot;SweetViz Tabs - Cylinders&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h4 id=&quot;exploratory-panels&quot;&gt;Exploratory Panels&lt;/h4&gt;

&lt;p&gt;This opens up an exploratory panel with useful information that &lt;strong&gt;compares the distribution of vehicles by cylinder to their average MPG.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/2021-08-03-sweetviz/03_cylinders_distribution.jpg&quot; alt=&quot;SweetViz Distribution - Cylinders&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We can see that:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;4 Cylinder Engines: Have the highest average MPG&lt;/li&gt;
  &lt;li&gt;8 Cylinder Engines: Have the lowest average MPG&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s that easy to explore your dataset!&lt;/p&gt;

&lt;h1 id=&quot;summary&quot;&gt;Summary&lt;/h1&gt;

&lt;p&gt;Exploratory data analysis can be automated with the python SweetViz reporting package. SweetViz makes it fast and easy to explore features and determine relationships to a target. In our case, we saw that 4 cylinder engines have the highest average MPG while 8 cylinder engines have the lowest average MPG.&lt;/p&gt;

&lt;h1 id=&quot;learn-more-business-process-automation-with-python&quot;&gt;Learn More: Business Process Automation with Python&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Businesses are transitioning manual processes to Python for automation.&lt;/strong&gt; Learn how in our new course, &lt;a href=&quot;https://university.business-science.io/p/python-for-data-science-automation-ds4b-101p&quot;&gt;Python for Data Science Automation&lt;/a&gt;. Perform and end-to-end business forecast automation using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pandas&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sktime&lt;/code&gt;, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;papermill&lt;/code&gt;, and learn Python in the process.&lt;/p&gt;

&lt;p&gt;&lt;span data-sumome-listbuilder-embed-id=&quot;54e6313db4cf24a7bf10be451ee765d85561e812a98e3acc20e3d4d63a65367d&quot;&gt;&lt;/span&gt;&lt;/p&gt;

&lt;!-- This is markdown code. It wont look formatted in your browser, 
    but will be fine when published. to the website --&gt;

&lt;!-- 
&lt;span data-sumome-listbuilder-embed-id=&quot;9cdb3104db3972bf15bfcdd21d0ae1d67082ed31c22aef5a700b86b9b2cdf5fd&quot;&gt;&lt;/span&gt;
 --&gt;

&lt;!-- 
&lt;br&gt;

&lt;div style=&quot;background-color:whitesmoke; padding:14px;&quot;&gt;
    &lt;p&gt;
    &lt;h2&gt;👇 Top R-Tips Tutorials you might like:&lt;/h2&gt;
    &lt;ol&gt;
        &lt;li&gt;&lt;a href=&quot;/code-tools/2021/05/04/mmtable2.html&quot;&gt;mmtable2: ggplot2 for tables&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;/r/2021/07/22/ggdist-raincloud-plots.html&quot;&gt;ggdist: Make a Raincloud Plot to Visualize Distribution in ggplot2&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;/code-tools/2021/05/18/marginal_distributions.html&quot;&gt;ggside: Plot linear regression with marginal distributions&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;/code-tools/2021/05/18/dataeditr.html&quot;&gt;DataEditR: Interactive Data Editing in R&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;/code-tools/2020/10/07/automate-excel.html&quot;&gt;openxlsx: How to Automate Excel in R&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;/code-tools/2020/09/22/automate-powerpoint.html&quot;&gt;officer: How to Automate PowerPoint in R&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;/code-tools/2021/03/02/use-dataexplorer-for-EDA.html&quot;&gt;DataExplorer: Fast EDA in R&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;/code-tools/2021/03/23/ggplot-code-with-tableau-esquisse.html&quot;&gt;esquisse: Interactive ggplot2 builder&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;/code-tools/2021/05/25/gghalves.html&quot;&gt;gghalves: Half-plots with ggplot2&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;/code-tools/2020/10/21/automate-pdf-with-r.html&quot;&gt;rmarkdown: How to Automate PDF Reporting&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;/code-tools/2021/05/11/patchwork.html&quot;&gt;patchwork: How to combine multiple ggplots&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;/code-tools/2020/12/08/geographic-map-visualization.html&quot;&gt;Geospatial Map Visualizations in R&lt;/a&gt;&lt;/li&gt;
    &lt;/ol&gt;
    &lt;/p&gt;
    &lt;p&gt;
        Want these tips every week? &lt;a href=&quot;https://learn.business-science.io/r-tips-newsletter&quot;&gt;Join R-Tips Weekly.&lt;/a&gt;
    &lt;/p&gt;
&lt;/div&gt;

&lt;br&gt;
 --&gt;

</content>
      
      <category>Learn-Python</category>
      
      <category>Python-Bloggers</category>
      
      <category>SweetViz</category>
      
      
      <category>python</category>
      
    </entry>
  
</feed>

