Productive Laziness with Python Programmability in SPSS Albert-Jan Roskam, PhD. Statistics Netherlands (CBS) ASSESS – York UK - October.

Slides:



Advertisements
Similar presentations
Python Whats in a name? Snake logos and mascot notwithstanding, its named after Monty Pythons Flying Circus Humor-impaired can safely.
Advertisements

Guy Griffiths. General purpose interpreted programming language Widely used by scientists and programmers of all stripes Supported by many 3 rd -party.
COMPUTER PROGRAMMING Task 1 LEVEL 6 PROGRAMMING: Be able to use a text based language like Python and JavaScript & correctly use procedures and functions.
Python for Science Shane Grigsby. What is python? Why python? Interpreted, object oriented language Free and open source Focus is on readability Fast.
Introduction to C Programming CE Lecture 1 Introduction to C.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
Introduction to Python. Outline Python IS ……. History Installation Data Structures Flow of Control Functions Modules References.
Scripting Languages CS 351 – Programming Paradigms.
Jonathan Huelman CSC 415 – Programming Languages
Introduction to Python (for C++ programmers). Background Information History – created in December 1989 by Guido van Rossum Interpreted Dynamically-typed.
Introduction to Python Dr. Bernard Chen Ph.D. University of Central Arkansas July 9 th 2012
Introduction to Python
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
By Zeng Sheng Liu. os - provides dozens of functions for interacting with the operating system >>> import os >>> os.system('time 0:02') 0 >>> os.getcwd()
Computer Science 111 Fundamentals of Programming I Overview of Programming.
By: Joshua O’Donoghue. Operating System Interface In order to interact with the operating system in python you will want to become familiar with the OS.
Python 0 Some material adapted from Upenn cmpe391 slides and other sources.
By Ryan Smith The Standard Library In Python. Python’s “Batteries Included” Philosophy Python’s standard library was designed to be able to handle as.
Introduction to PythonIntroduction to Python SPARCS `08 서우석 (pipoket) `09 Summer SP ARCS Seminar`09 Summer SP ARCS Seminar.
H3D API Training  Part 3.1: Python – Quick overview.
August 29, 2005ICP: Chapter 1: Introduction to Python Programming 1 Introduction to Computer Programming Chapter 1: Introduction to Python Programming.
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
Python. By Jawad. What Is Python? Python is an open-source object-orientated scripting language. Python is good for embedding snippets to run a program.
Python – May 11 Briefing Course overview Introduction to the language Lab.
Intro to Python Adriane Huber Debbie Bartlett Python Lab #1Python Lab #1 1.
Overview Intro to functions What are functions? Why use functions? Defining functions Calling functions Documenting functions Top-down design Variable.
Introducing Python CS 4320, SPRING Resources We will be following the Python tutorialPython tutorial These notes will cover the following sections.
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
I Power Higher Computing Software Development Development Languages and Environments.
OCR GCSE Computing © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 1: Introduction.
Introduction to Python Origins Nature of Python Importance of Python Example.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
8 January 2016Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems
Python’s Standard Library Part I Joe Houpert CS265.
Python  Monty or Snake?. Monty?  Spam, spam, spam and eggs  Dead parrots  Eric Idle, John Cleese, Michael Palin, etc.
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
Getting Started With Python Brendan Routledge
PYTHON PROGRAMMING. WHAT IS PYTHON?  Python is a high-level language.  Interpreted  Object oriented (use of classes and objects)  Standard library.
Quiz 1 A sample quiz 1 is linked to the grading page on the course web site. Everything up to and including this Friday’s lecture except that conditionals.
Introduction to Python for System Administrators Toshio Kuratomi May 2011.
Introduction to Programming
Fundamentals of Programming I Overview of Programming
Lesson 06: Functions Class Participation: Class Chat:
Python Programming Unit -1.
Programming For Big Data
CST 1101 Problem Solving Using Computers
Scripting Languages Info derived largely from Programming Language Pragmatics, by Michael Scott.
CSC 458– Predictive Analytics I, Fall 2017, Intro. To Python
Variables, Expressions, and IO
Introduction to Programming
Functions CIS 40 – Introduction to Programming in Python
Data Analysis using Python-I
TRANSLATORS AND IDEs Key Revision Points.
Do you know this browser?...
What Is a Program? A program is like an algorithm, but describes a process that is ready or can be made ready to run on a real computer Retrieved from:
Introduction to Python
Introduction to Python
CSC 458– Predictive Analytics I, Fall 2018, Intro. To Python
Introduction to Programming Using Python PART 1
Lesson 06: Functions Class Chat: Attendance: Participation
Python’s Standard library part I
Introduction to Programming
12th Computer Science – Unit 5
Chapter 1: Programming Basics, Python History and Program Components
Training Up: Intro to Python
General Computer Science for Engineers CISC 106 Lecture 03
Python Basics. Topics Features How does Python work Basic Features I/O in Python Operators Control Statements Function/Scope of variables OOP Concepts.
Ungraded quiz Unit 1.
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Productive Laziness with Python Programmability in SPSS Albert-Jan Roskam, PhD. Statistics Netherlands (CBS) ASSESS – York UK - October 2015

Python: What? Why? (1) General purpose language (unlike R) Easy to learn, but not a toy language “Readability counts” Developed in 90s by Van Rossum (Amsterdam) Monty Python’s Flying Circus Free, incl. lots of additional libraries Python is everywhere, incl. in SPSS! Python 2 and 3

Python: What? Why? (2) Python will help you become more productive Less code to maintain Less boring, repetitive work Do things that cannot be done using traditional syntax (or macro language) If you know Python (R, SQL, SPSS, …) you increase your market value!

Some language characteristics Case-sensitive Indentation mandatory (unlike e.g. SPSS) Easier to follow the program logic Many datatypes (str, int, float, list, tuple, etc.) SPSS just has string and float Starts counting at zero (unlike SPSS, R) "Batteries included" philosophy

Python and SPSS External mode: SPSS in a Python program Internal mode: Python program in SPSS Task – Python module Job automation/generalization - spss Access to metadata - spssaux Access to case data – spssdata, spss Access to output data – SpssClient, spssaux

Python and SPSS A very simple program: BEGIN PROGRAM PYTHON. print "Hello world" END PROGRAM. Woaah, that was useless! But: "print" is a useful diagnostic command Just like: help(), type(), repr(), len(), dir() e.g.: len("abc") # returns 3

"Run only with SPSS v22"

SPSS Macro vs Python function

Access meta data

Some useful libraries LibraryWhat it doesStandard library? os, os.path sys (date)time glob re subprocess csv cElementtree pyodbc openpyxl xlrd, xlwt savReaderWriter numpy pandas Operating system stuff Python interpreter stuff Time/date, formatting, etc List files that match a pattern Regular expressions Run external programs Read/write.csv files Read/write.xls files Read/write from/to databases Read/write.xlsx Read/write.xls Read/write.sav,.zsav Numerical Python R-like DataFrames, etc. Yes No

Resources Python in general Many more (free) tutorials on the internet Python and SPSS SPSS Programming and Data management Tip: Choose the edition that matches your SPSS version! Python Scripting Guide for IBM SPSS Statistics:

Mailing lists and forums Python in general Python tutor Python main (high volume!) list list Python and SPSS IBM Predictive Analytics (formerly devWorks) ums/ ums/ SPSS-L bin/wa?A0=SPSSX-L (not very Python-oriented) bin/wa?A0=SPSSX-L