The Simplicity of Python (an example)

Previously, I posted on how to forward fill missing data in columns of data in R and Excel. I just figured out how to do this in Python, and was blown away. Ready?


data = Series(['A','B','C','D','E','F'], index = [0,2,5,7,12,14])
data.reindex(range(14),method='ffill')

Done! It's as simple as telling Python, "Hey I want to reindex the 15 items (0-14) with a forward-fill method". And Python responds, "Done".

Me: "OK, Jump!"

Python: "How high?"

Also, I should mention that "method='bfill'" is... you guessed it... a backwards fill method. Enjoy.

ps- I think that the more I post about Python, the shorter my posts will be. (Thanks to the simplicity of Python).

This entry was posted in analysis, data, Python and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *