Python Adventures – 03

Sharing code and delving into Python & Pandas.

My GitHub repository (which I must reorganize prior to sharing a link) where I will endeavor to post a copy of all the code I create for my Python Adventures. I look forward to open reviews and improvements.


The Python & Pandas example based on Data-Driven Security Listing 2-2:

#Python & Pandas data frame example similar to Data-Driven Security Listing 2-2

# create a new data frame

import numpy as np

import pandas as pd


#create a new data frame of 5 IT and OT assets and vulnerability counts

assets_df = pd.DataFrame( {

“name” : [ “ControlRoom-PC001″,”PLC-002″,”RTU-003″,”DCS-004″,”FilePrint-SVR005” ],

“os” : [ “WinXP”,”Fatek”,”GE_D20MX”,”DLink_DCS-2000″,”W2K8″ ],

“highvulns” : [ 25,5,12,6,0 ]

} )


#review the data frame structure & content




#shows a sample or slice of the available operating systems input



#Addition of a new column with IP address information & new column

assets_df[‘ip’] = [ “”,”″,”″,

“”, “”]


#Display assets only with greater than 10 high vulnerabilities & new column



#Categorize assets in zones and add a new column

assets_df[‘zones’] = np.where(

assets_df.ip.str.startswith(“10.10.2”), “Zone1”, “Zone2”)


#final inspection of code input



If all goes well the output should look something like:

What is nice about Python with Pandas is the nice output layout. When I do the same thing in R, no table layout without work, more difficult to read through. This would be of greater importance when handling larger sets of data and limited knowledge of Python and R.

Why did I pick Operations Technologies (OT) and IT resources? OT is what runs much of our physical world nowadays, not shiny IT like new servers or laptops. IT controls our virtual selves, our data and not for example traffic lights, railway signaling, medical equipment or factories. For this reason, I will be presenting Confessions of an IT/OT Hacker at the European Industrial Control Systems Summit, London, UK Royal Aeronautical Society, 22 & 23 September, 2014. Everyone in IT and should familiarize themselves with the basics of Industrial Control Systems.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: