Problem : This is the error I am getting and, as far as I can tell, there is nothing useful […]
Category: Python
Running shell command and capturing the output
Problem : I want to write a function that will execute a shell command and return its output as a […]
Convert string “Jun 1 2005 1:33PM” into datetime
Problem : How do I convert the following string to a datetime object? “Jun 1 2005 1:33PM” Solution : datetime.strptime […]
How to download a file over HTTP?
Problem : I have a small utility that I use to download an MP3 file from a website on a […]
How to iterate over a list in chunks
Problem : I have a Python script which takes as input a list of integers, which I need to work […]
How to flatten a hierarchical index in columns
Problem : I have a data frame with a hierarchical index in axis 1 (columns) (from a groupby.agg operation): USAF […]
How do I execute a string containing Python code in Python?
Problem : How do I execute a string containing Python code in Python? Solution : For statements, use exec(string) (Python […]
How to convert string representation of list to a list
Problem : I was wondering what the simplest way is to convert a string representation of a list like the […]
How to uninstall Python 2.7 on a Mac OS X 10.6.4?
Problem : I want to completely remove Python 2.7 from my Mac OS X 10.6.4. I managed to remove the […]
How to step through Python code to help debug issues?
Problem : In Java/C# you can easily step through code to trace what might be going wrong, and IDE’s make […]