DelphiPythonPython GUIWindows

Powerful Data Analysis And Manipulation Using Pandas Library In A Delphi Windows App

Are you looking for powerful tools to analyze and manipulate structured data, and build a nice GUI for them? You can build fast, expressive, insightful, and scalable data analysis tools easily by combining pandas and Python4Delphi library, inside Delphi and C++Builder.

pandas is a Python package that provides fast, flexible, and expressive data structures designed to work with structured (tabular, multidimensional, potentially heterogeneous) and time-series data easily and intuitively.

pandas aim to be the fundamental high-level building block for doing practical, real-world data analysis in Python. Additionally, it has the broader goal of becoming the most powerful and flexible open-source data analysis/manipulation tool available in any language. It is already on its way toward this goal.


10+ Amazing pandas Examples inside the Delphi Windows GUI App

This post will guide you on how to run various data analysis and manipulation examples using the pandas library and using Python for Delphi to display it in the Delphi Windows GUI app.

First, open and run our Python GUI using project Demo01 from Python4Delphi with RAD Studio. Then insert the script into the lower Memo, click the Execute button, and get the result in the upper Memo. You can find the Demo01 source on GitHub. The behind the scene details of how Delphi manages to run your Python code in this amazing Python GUI can be found at this link.

0 rundemo1 6813476

These examples will cover almost various functions and methods you are most likely to use in a typical data analysis process. Let’s run them all in our Python4Delphi Demo01 GUI:

1. Reading the CSV file into a pandas dataframe

1 8433606


2. Check the shape or dimension of the dataset

2 1364746


3. See the column labels of the DataFrame

3 1380595


4. Dropping columns

We want to remove 4 columns: ‘RowNumber‘, ‘CustomerId‘, ‘Surname‘, and  ‘CreditScore‘. The axis parameter is set as 1 to drop columns and 0 for rows. The inplace parameter is set as True to save the changes:

4 3148081

We dropped 4 columns so the number of columns reduced to 10 from 14.


5. Select particular columns while reading

We want to read only specific columns: ‘Gender‘, ‘Age‘, ‘Tenure‘, and ‘Balance‘:

5 1942786


6. Reading a part of the dataframe (from the first n number of the rows)

We want to read the first 5000 rows of the CSV file:

6 3112155


7. Select rows from the end of the file

We can also select rows from the end of the file by using the skiprows parameter. skiprows=5000 means that we will skip the first 5000 rows while reading the csv file:

7 7327514


8. Draw a small sample to work

We can either use the n parameter or frac parameter to determine the sample size.

  • n: The number of rows in the sample

8 a 1645484

  • frac: The ratio of the sample size to the whole dataframe size

8 b 5432542


9. Checking the missing values

Using the isna with the sum function, we can see the number of missing values in each column:

9 5563312


10. Adding missing values using loc and iloc

The “loc” and “iloc” will select rows and columns based on index or label.

  • loc: selects with label
  • iloc: selects with index

10 7799736


11. Fill the missing values

  • Fill NA using the most common value (mode)

  • Fill NA using the mean value

11 9959113


Congratulations, now you have learned how to run various data analysis and manipulation examples using the pandas library and using Python for Delphi to display it in the Delphi Windows GUI app!

Check out the pandas library for Python and use it in your projects: and

Check out Python4Delphi which easily allows you to build Python GUIs for Windows using Delphi:

References & further readings

[1] Hakim, M. A. (2022). Build The Ultimate GUI For Pandas To Perform Complex Data Analysis. Embarcadero Blogs.

[2] Yıldırım, S. (2020). 30 Examples to Master Pandas. Towards Data Science.

Related posts
CodeDelphiDelphiFMXLearn PythonProjectsPythonPython GUI

How to Build An Image Editor Using DelphiFMX Python Package

CodeDelphiDelphiFMXLearn PythonProjectsPythonPython GUI

How To Use LangChain and DelphiFMX To Create a Custom Chat App

CodeDelphiDelphiFMXLearn PythonProjectsPythonPython GUI

How To Build an Iris Flower Classification GUI App With DelphiFMX

CodeDelphiDelphiFMXLearn PythonProjectsPythonPython GUI

How To Implement an Art Style Transfer GUI App with the Python Delphi Ecosystem

Leave a Reply

Your email address will not be published. Required fields are marked *