PyGWalker: Your Python Tool for Easy Data Exploration and Visualization, Just Like Tableau!¶

Introduction:¶

As data scientists and analysts, we frequently dive into data using tools like pandas, matplotlib, and seaborn. These tools, though effective, often fall short in terms of interactive data exploration and visualization.¶
Introducing PyGWalker (pronounced "Pig Walker") - a Python library that seamlessly connects Jupyter Notebook and Graphic Walker, an open-source Tableau alternative. PyGWalker empowers you to transform your pandas dataframe into an intuitive, Tableau-like interface for dynamic data exploration.¶
To start exploring PyGWalker and leveraging its capabilities for interactive data exploration and visualization, you can follow these steps:¶
Step 1 :Install PyGWalker¶
In [ ]:
!pip install pygwalker
Step 2:Import the required packages.¶
In [ ]:
import pygwalker as pyg
import pandas as pd
import io
Step 3: Upload the data.¶
In [ ]:
data = pd.read_csv('empdata.csv')
print(data.head())
   EmployeeNumber Attrition     BusinessTravel              Department  \
0               1       Yes      Travel_Rarely                   Sales   
1               2        No  Travel_Frequently  Research & Development   
2               4       Yes      Travel_Rarely  Research & Development   
3               5        No  Travel_Frequently  Research & Development   
4               7        No      Travel_Rarely  Research & Development   

   DistanceFromHome                JobRole  JobSatisfaction  MonthlyIncome  \
0                 1        Sales Executive                4           5993   
1                 8     Research Scientist                2           5130   
2                 2  Laboratory Technician                3           2090   
3                 3     Research Scientist                3           2909   
4                 2  Laboratory Technician                2           3468   

   NumCompaniesWorked  PercentSalaryHike  TotalWorkingYears  WorkLifeBalance  \
0                   8                 11                  8                1   
1                   1                 23                 10                3   
2                   6                 15                  7                3   
3                   1                 11                  8                3   
4                   9                 12                  6                3   

   YearsAtCompany  
0               6  
1              10  
2               0  
3               8  
4               2  
Step 4: Exploring Data with PyGWalker.¶
In [35]:
pyg.walk(data)
Out[35]:
Once the code runs, we will see the interactive data visualization tool that is very similar to Tableau.¶
Click on the data tab to quickly see the data and the data types. To go back to the visualization area, click visualizations.¶

The PyGWalker interface is organized as follows:¶

  1. Left Panel: It shows the variables you're working with.
  2. Central Area: This is where you create visualizations. You can drag and drop variables to the X and Y-axis boxes.
  3. Customization Options: You have tools for filters, color, opacity, size, and shape to customize your visualizations.

Let's dive in and use these tools to create some exciting visualizations.

Creating a Bar Plot:¶

Drag and drop the column "Departmentnt" to y-axis and "MonthlyIncome" to x-axis.¶
In [24]:
pyg.walk(data)
Out[24]:

Adding filters:¶

We can also filter our data to select only a portion of data based on any column. Let's drag the YearsAtCompany to the filter box and select the number years (min and max).¶
In [32]:
pyg.walk(data)
Out[32]:
Similarly, you can explore other powerful tools like color, opacity, size, and shape adjustments to fine-tune and customize your visualizations, making them even more insightful and visually engaging.¶

Conclusion:¶

In a nutshell, PyGWalker is a powerful and user-friendly Python tool for interactive data visualization and analysis. By following this tutorial, you've learned how to install and use PyGWalker to create dynamic visualizations and uncover insights in your data. Whether you're a data scientist, analyst, or just someone looking to visualize data effectively, PyGWalker is a valuable addition to your toolkit. Its flexibility and ease of use make it an indispensable asset in your data analysis workflow. Give it a try today and supercharge your data exploration!¶