Basic Built-in Data Types in Python for Data Science




Python is one of most used programming language in data science. It is a general purpose language and helps to generate insights quickly. Python community has developed a whole lot of very useful data science libraries such as NumPy, Pandas, Scikit Learn etc.

One of main reasons of its popularity among data scientists is its simple syntax and data types. Python has got following built-in data types;

  • Integer
  • Floating-point numbers
  • Complex numbers
  • Strings
  • Boolean type, and
  • Boolean context.

In this article we will quickly look into how the objects of these types look like, and how to represent them.

Integers

In Python 3, there is no limit that how long an integer value can be in. It depends on the amount of memory your system has. If enough memory is there, an integer can be as long as you need it to be.

Floating-Point Numbers

In Python, float values are specified with a decimal point and the float type designates a floating-point number. Alternatively scientific e or E can be added to specify scientific notation after positive or negative integer.

Complex Numbers

Such numbers which are specified as +j are known as complex numbers. Such as:
>> 7+5j
(7+5j)
>> type(7+5j)
<class 'complex'>

Strings:

The sequences of character data are known as Strings. Using single or double quotation marks literals strings can be separated. All characters are part of the string between the opening separator and the associated closing separator
It must be mentioned that Python can contain as many characters as you want in a string. Your machine's memory processing is the only restriction. A string can also be empty.

Boolean Type

The objects of Boolean type may have one of two possible values, True or False:
>> type(True)
<class 'bool'>
>> type(False)
<class 'bool'>

Boolean Context

Boolean context is often used to evaluate expressions in Python, meaning they are interpreted to represent truth or falsehood. Sometimes “truthy” is used for a value that is true in Boolean context and one that is false in Boolean context is said to be “falsy.”

Truthiness

Such boolean objects that are equal to True are “truthy”, and those which are equal to False are falsy are evident by the “truthiness.”

Got A Data Science Question?

Ask our experts anything about machine learning, analytics or statistics.