A Byte of my 2.2-lb Brain

Just sharing stuff…

Add Multiple Columns to Pandas Dataframe from Function

If you have a pandas data frame mydf that has, for example, two columns mydate and mytime (both are of type datetime), to add three more columns: hour, weekday, and … Continue reading

May 5, 2015 · Leave a comment

Sorting Dictionaries in Python

Sort by Values Here’s a code snippet to sort dictionaries by their values. The output is a list: [(‘papaya’, 2), (‘avocado’, 3), (‘apple’, 10), (‘banana’, 12)] To reverse the list … Continue reading

April 17, 2015 · Leave a comment