Archive | QR Code RSS feed for this section

Pandas and Python…..Oh My.

21 Dec

Crunching data and rearranging data in Python is cool, but I really need to visualize it. Nothing fancy, just a bar or line chart. I recently saw a D3 implementation in Python – awesome, but for now I just want to stick to Matplotlib. I grabbed a few books on scientific python and data in python. They seem to love IPython – the web notebook is pretty cool. Another tool that is often mention is Pandas. This is what I want to use – it uses Matplotlib for plotting. The one feature that caught my attention right away was the DataFrame. Think of it as a Excel spreadsheet, then if anyone asks about it, tell them it’s like data.frame() in R.  When I learn something, I like to start bare bones, then build it up with extra options and variations. I have put together some very minimal examples of plotting DataFrames and a Series in Pandas. From here you should have a good grasp of how to do more.

Plotting a Series.

Plotting a Series.

Plotting a Series requires a Series and a type of chart. Here is my code:

from pandas import Series
import matplotlib.pyplot as plt

Series.plot(a, kind=’bar’) #change to ‘barh’ for horizontal. Can also declare kind=’line’

Plotting a DataFrame

Plotting a DataFrame


Plotting a DataFrame is what I need the most in my work. Earlier I compared a DataFrame to an Excel spreadsheet. Here is what a DataFrame looks like:

Simple DataFrame

Simple DataFrame

Looking at the DataFrame and the Chart,  notice that each row plots as a group labeled by the index and columns. The DataFrame is created by passing a Numpy Array.:

df=DataFrame(a, columns=[‘a’,’b’,’c’,’d’,’e’], index=[2,4,6,8,10])

To plot the chart, just call plot and pass a type. Here is the complete code:

from pandas import DataFrame
import matplotlib.pyplot as plt
import numpy as np

df=DataFrame(a, columns=[‘a’,’b’,’c’,’d’,’e’], index=[2,4,6,8,10])


This is how I learned to use Pandas DataFrame and to plot my data. Knowing this, I felt much more comfortable looking at more advanced examples online.

Make your own QR Codes

9 Nov

QR Codes are fun – as long as you’re not just taking me to Old Navy to buy a sweater. Want to generate your own? I will show you how in Python.

Note: Python has many modules that make it easy to do almost anything you can think of. Use them. They will make your life easier. To find some go to pypi.

Download and install the QrCode Package. You also need the Python Imaging Library (PIL).

All I did was copy the sample and add a variable to pass the data and a save(). Configure the program to pass a value via the command prompt, QT or the web – give a CherryPy application a shot!

Here is all the code it takes:

import qrcode
import PIL


You can do more by using the QR Code Class – change the version and error correction levels. You can drop the show()too.

Here is my QR Code to Google.


The History of Albuquerque in QR Codes

22 Feb

So I had an idea where I would place QR Codes around Downtown Albuquerque. When you scan the code, you would see a photograph from between 1890 -1927 of the site you are standing on. I even used the New Mexico Centennial logo with my codes. I created a map, using leaflet.js, of where the six codes would be place (2 were placed at 1st and Central). The map is mobile capable and is at popups show you what photo you would see when you scan the code.

In Albuquerque we have a group called the Downtown Action Team. They clean the City every morning and I must say they do a good job. There is not a single piece of paper attached to any posts in this city. This should have been a clue that my project was doomed to fail. My QR Codes were gone within 2 days.

Well, it was a nice try and a cool project. Here is a sample of my QR Codes – I would like to replace the middle of the code with a Zia in the future.

Why Jon Barocas Doesn’t Understand QR Codes

17 Feb

Mashable ran a piece yesterday by Jon Barocas titled: Why QR Codes Won’t Last. I am not going to argue that QR Codes are going to last, but I will argue that Jon Barocas is blinded by his professions inability to be creative and do anything innovative. Marketers have abused QR Codes. They have turned a potentially useful tool in to nothing more than a URL to their lame website. They also misunderstand what we want from them and from QR Codes. Until marketers stop applying new technology in old ways, QR Codes in marketing is doomed for sure. But for the rest of us, they offer a an innovated way to share information.

Jon starts by saying only 5% of Americans have scanned a QR Code and that this is a problem. 5% is 14 million people. That’s a large number people. But for marketing, they need more scans.  He attributes the low number of people scanning QR Codes to the fact that people “are visual animals..” and that “…a more visual alternative to QR codes would not only be preferable to consumers, but would most likely stimulate more positive responses to their presence. ” A QR Code dropped in to an advertisement in a magazine does not tempt me to scan it. Jon is right about this. But what he is missing, is that when I am reading a magazine, your ad may grab my attention for two seconds, but I am not interested in your product at the moment. I will not put down my magazine and go to your website. I am enjoying my magazine, which your ads are interfering with. Let’s be honest, I am probably reading this magazine in my library – and by library I mean bathroom. I may not even be reading a print copy of your magazine. If I am reading it on my phone or iPad, what am I going to scan your code with?

QR Codes can do much more than take me to your website to buy stuff. Look at any of my past posts to see a QR code link to building models, real time maps, and databases. Do something interesting. I am walking around with a dual core processor and an internet connection in my pocket. If you can only send me to a website to buy cargo pants, you have lost me. You have bored me. You are applying a new technology to your old, tired, marketing methods.

Jon has a solution that will replace QR Codes – MVS (mobile visual search). Yay! I can scan a company logo and it will take me to their website to buy stuff. Because as a human of normal intelligence, I clearly don’t know that ,, will take me to their sites. URLs are so hard to figure out. Jon, I know how to get to your site. It is not why I would want to scan a QR Code. And I am not scanning your logo to take me there either.

Jon ends by telling you how QR Codes will infect your phone with a horrible virus or a trojan. MVS is much safer, because hackers and malware writers don’t write for MVS….Yet, Jon. Modifying your logo slightly may be all I need to make your MVS as dangerous as a QR Code. Jon is right. QR Codes can be a bit dangerous. Ever used a URL shortener? anyone? These shortened URLs can do exactly the same thing. Who knows where you are clicking. The internet is a dangerous place but I am not giving up on it.

I don’t know what the future of QR Codes will be. But I can tell you that marketers and social media consultants and new media guru seo optimizers and whatever these people decide to call themselves nowadays say, they are missing the boat. Stop forcing your old ways on new technology. Think of new ways to go with new technology. Do something creative. Wow me. But don’t say the sky is falling because nobody is scanning a QR Code to buy garbage from your online store.


It has bothered me that I didn’t include the most obvious response to the dangers of scanning a QR Code. Depending on the application you use – I use RedLaser – it tells you where you are going and asks if you want to go!

Here is a QR Code to  <—not a real website.


When I scan this QR Code, my app tells me exactly where I am going.

And there you have it. A few simple lines of code that prompt the user to   accept the redirect. Security risk averted.

QR Code Logging

16 Feb

Today someone hit my blog while searching for a way to log QR Code scans. I am going to give a very short explanation on how to do this. This is the simplest way I can think of.

Go to

Get a free account.

Shorten the URL for the page you want the QR Code to link to.

It will be added to your list of URLs. Click “Info Page+”.

The QR Code for your site is in the upper right hand corner. Save image as…

From now on, you can log on to and go to the Info Page+ to find out how many scans you have had. Or just type the shortened url with a + after it.

That’s really all there is to it. You know a better way, let me know.

Hacking the City with QR Codes

15 Feb

I got the idea to connect a QR Code to a camera. But I needed something interesting. How about when you scan the code you see a picture of yourself?

I found a live camera from the KOB TV channel in Albuquerque. I extracted the feed from their page and wrote my own website to display their feed.

I then connected the QR Code to my page. I printed the code and laminated it with tape. I went to the location that the camera watches and placed the code on a post.

When you scan the code, you are taken to a website showing you standing at the corner looking at the code! Here I am looking like a fool on my phone.

That is me standing on the corner. Here is the QR Code. It is much more fun if you are at the location.

NOTE: The camera moves during the day. The codes work until about 2:00.

Link 3D Model to QR Code

3 Feb

I have been bouncing ideas off the wall trying to think of a way to link a QR Code to a 3D model – from Revit. The from Revit part is important. I do not want just a bunch of geometry, but I want to have all the data in the model as well. The hardest part was trying to find a way to get the 3D model on a mobile device. I finally remembered how I used Inventor Publisher Mobile for iPhone to display my 3D Revit models. So now all I had to do was bridge the gap from a QR Code to the application.You must have IPM Viewer on your phone for this to work. It is free.

PHP to the rescue, yet again! Architects, this is why you need to understand code. You do not need to be a code monkey but need to know how to read, modify, and copy code from other places.

So here is the code. Put this in a file on your webserver. Mine is called ipm.php.


Here is the QR Code that links to the PHP file:


When you scan this code, you should see a page that looks like this:





Select the Open in IPM Viewer and the file will be loaded in the application. You will then have a full Revit model, in 3D, with all the data, on your phone.

Notice the popup saying “basic roof?” I double tapped an object and got the popup. Click the  arrow to see all the properties associated with it.