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 Demo1 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 Demo1 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.


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



2. Check the shape or dimension of the dataset



3. See the column labels of the DataFrame



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:


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’:



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:



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:



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


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



9. Checking the missing values

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



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



11. Fill the missing values

  • Fill NA using the most common value (mode)

  • Fill NA using the mean value



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:

Related posts
DelphiLearn PythonPythonPython GUIRAD Studio

Why You Should Know About SQLite For Your Windows Apps

Learn PythonPythonPython GUIVideos

How To Make Matplotlib Charts To Visualize Data

DelphiPythonPython GUIWindows

What You Need To Create A Secure Python Password Generator

DelphiPythonPython GUIWindows

How To Make A GUI For Learning Python Using Turtle Library

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *