X
Icon


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


Best Practices , Data Analytics , Tech Tip



Posted By

By Danny Betancourt


Related Posts
5 Ways Manufacturers are Using Analytics to Make Data-Driven Decisions
Nov 20 At times, any manufacturing enterprise can feel like a web of mysteries and riddles. Just keeping track of all the moving parts—from supplier relationships to...
Auditing the Material World
Aug 24 Numbers in a population generally aren’t evenly distributed.  Just ask Vilfredo Pareto (1848-1923), the famed Italian economist whose observations have been ...
In My Opinion – The Value of Timely Reporting
Jul 11 In today’s fast-paced organizations, new developments can unfold at a moment’s notice. Critical decisions often must be made on compressed time sche...
BROWSER NOT SUPPORTED

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

×