Frequently Asked Question
Press "Ctrl + F" to find the keyword of your interest.
If you wish to have a direct link access to the video timestamps, please follow these instructions.
Found this video helpful? Why not take the whole HIL Specialist course? A Certificate is waiting for you for free at HIL Academy.
Would you or your organization benefit from having these videos narrated in your native language? Contact us and let us know if you wish to contribute.
TRANSCRIPT
Hello and welcome. In the Python Basics lesson, we covered the basics of what you need to know
in Python to get started with test automation programming. In this lesson, we will look at
some of the important publicly available Python packages that will help us do this.
As mentioned in the last lesson, we are using PyCharm to write and execute Python Code.
A guide for how to set up your PyCharm environment is also available in the Materials tab.
Since Python is an open-source programming language, many people and companies have
developed publicly available function libraries for it, called packages. Here, let s take a
look of some very common packages, that come by default with Python installation, which optimize
mathematical operations and data handling and come by default with each Python installation.
These are numpy , pandas , and math .If your Python does not have these libraries
installed, you can do so by running the 'pip install' command. 'pip' is
a package-management system written in Python used to install and manage software packages.
It connects to an online repository of public packages, called the Python Package Index. To
check which libraries are installed, open the Pycharm terminal and type 'pip list'.
To install a new library, use the 'pip install' command followed by the library name.
As you can see, some libraries like pandas have dependencies on other libraries,
and these are installed automatically.There are multiple ways to import
a package. The easiest is to simply import the whole library as shown here.
Once math is imported, you can access all its functions and methods by using
math.<function or attribute> . In Pycharm, after importing the package,
you can type math. to check all the available functions in the popup screen.
An alternative is to import specific functions from a library.
This lets you avoid having to type the entire package name each time you use one of its methods.
A third way to import, is by using an alias with as .
This gives the package a shorter name, making the code more readable.
Now let s take a look at the pandas library. This is a great library for manipulating large
amounts of data and is used by the Typhoon HIL toolchain to return captured results.
The package also helps to organize and extract information from data using the datatype called
dataframe which is a 2-dimensional table of rows and columns similar to a spreadsheet.
Let s start by creating a dataframe like the one returned by Typhoon s capture.
When we print a Dataframe, we can see its structure, consisting of 4 columns. The
first is called an index, and it is used to identify the lines of the Dataframe.
The rest of the columns, are the data for three-phase signals.
To better visualize the signal, we can plot them using the .plot() method.
It is possible to select columns of the dataframe, except the index,
by specifying them between [] . If you wish to select multiple columns, provide them as a list.
To access the index, we can use df.index .
We can slice the dataframe, selecting specific time intervals.
If you use integer numbers, it will slice considering samples.
You can also slice using time deltas. For example,
here we slice a dataframe to plot one fundamental cycle.
Pandas has a very powerful set of functions to extract information and manipulate data.
For example, to obtain the maximum, minimum, and average values for each one of the series,
you only need to use the .max() , .min() , and .mean() methods.
You can find many other functions in the pandas documentation or by searching the web.
This is all for the Python basics lessons. In the next lessons,
you will learn how to use Pytest, a very powerful Python testing framework.
Thank you for watching!