X
Icon

The 21st Minute


Blog
Blog Image

Give Python a Go


Python is considered the official programming language for non-programmers. It gives you increased flexibility and expansive access to your data. For those using IDEA 10.3 or higher, you can leverage the power of Python to build your own advanced analytics or use existing Python scripts to identify outliers within both numeric and character fields.

Let’s get started with a few tips to ease you into this new user-friendly programming language:

Comments

Python uses the # to write comments. Comments do not interfere with your instructions; they are simply notes for you and anyone interacting with your code.

# This is an example of a comment. For example, I can use this to explain how a complex equation works.

Declaring, Assigning, and Accessing Variables

Python is classified as a weakly typed language. Variables are not required to declare their datatypes nor do functions force parameters to be a certain type. It’s also a dynamic language, meaning variables do not need to be declared and all types are inferred at assignment.

Text

Text data is very simple to work with in Python. It may be interacted with directly without the requirement of first saving the value to a variable. Text values may be declared with either quotes or apostrophes. This simplifies the inclusion of quotes and apostrophes inside of your data without needing to use an escape sequence.

# As shown here, digits did not declare a type. It immediately took a value.

digits = "1234567890"

# If you’d like to isolate only the even numbers, for example, you may do so with the # variable or data directly.

digits[1::2]

"1234567890"[1::2]

Numbers

Python handles numbers for you in the background. It essentially supports two types of numbers: Integers and floating point values. However, you don’t need to worry about telling it what kind of numbers you have due to its type inference.

whole_number = 10

floating_point = 3.1415

Boolean Values

Boolean values are logical outcomes of either true or false. They are used in all sorts of ways, but most commonly is control flow statements like the if statement. To declare one, true or false must be capitalized in Python.

passed_test = True

Lists

Lists are more or less what they sound like. They are collections of data organized into a linear list. True to Python’s weakly typed nature, lists can hold any combination of datatypes (contrary to compiled languages). They are useful for keeping related pieces of information together and be accessed with an index value. This is an example of their syntax:

bundle_of_data = ["text", 5, True, 2.1]

bundle_of_data[0]

Slicing

In Python, slicing is how elements are retrieved from lists using a precise pattern. Indexing only retrieves a single value. Slicing, as seen in the even digits example, returns another list of data depending on the pattern given to it. The pattern follows this form: [starting point : ending point : counting by].

Ready to learn more about Python? Refer to these past Tech Tips for a deeper dive:

Exploring IDEA's Built-in Power of Python

Infusing Python into Your Analysis with IDEA


Applications , Best Practices , Data Analytics , Tech Tip



Posted By

By Danny Betancourt


Related Posts
Give Python a Go
Mar 29 Python is considered the official programming language for non-programmers. It gives you increased flexibility and expansive access to your data. For those usin...
Data Acquisition Tips from the Pros
Mar 29 Regardless of what data analytics tool you use, your results are only as good as the data you’re using. Data acquisition and preparation is a S. L. O. W. proc...
Fraud Data Analytics: A Worked Example for Ghost Employee Fraud Schemes
Feb 11 Ghost employee schemes are a common fraud scheme during which there are people on the payroll who don’t work for the company in question but do collect a sala...
BROWSER NOT SUPPORTED

This website has been designed for modern browsers. Please update. Update my browser now

×