{"id":1686,"date":"2019-02-06T06:35:19","date_gmt":"2019-02-06T06:35:19","guid":{"rendered":"https:\/\/www.aiproblog.com\/index.php\/2019\/02\/06\/a-blast-from-python-past-part-2\/"},"modified":"2019-02-06T06:35:19","modified_gmt":"2019-02-06T06:35:19","slug":"a-blast-from-python-past-part-2","status":"publish","type":"post","link":"https:\/\/www.aiproblog.com\/index.php\/2019\/02\/06\/a-blast-from-python-past-part-2\/","title":{"rendered":"A Blast from Python Past &#8212; Part 2"},"content":{"rendered":"<p>Author: steve miller<\/p>\n<div>\n<p><a href=\"https:\/\/storage.ning.com\/topology\/rest\/1.0\/file\/get\/969955376?profile=original\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"https:\/\/storage.ning.com\/topology\/rest\/1.0\/file\/get\/969955376?profile=RESIZE_710x\" class=\"align-full\"><\/a><\/p>\n<p>Last week I posted the<span>\u00a0<\/span><a href=\"https:\/\/www.datasciencecentral.com\/profiles\/blogs\/a-blast-from-python-past\">first<\/a><span>\u00a0<\/span>of a three-part series on basic data programming with Python. For that article, I resurrected scripts written 10 years ago that deployed core Python data structures and functions to assemble a Python list for analyzing stock market returns. While it was fun refreshing and modernizing that code, I&#8217;m now pretty spoiled working with advanced libraries like NumPy and Pandas that make data programming tasks much simpler.<\/p>\n<p>This second post revolves on a brief showcasing of<span>\u00a0<\/span><a href=\"http:\/\/www.numpy.org\/\">NumPy<\/a>,<span>\u00a0<\/span><a href=\"https:\/\/en.wikipedia.org\/wiki\/NumPy\">a comprehensive library created in 2005 that extends the Python core to accommodate<\/a><span>\u00a0<\/span>&#8220;large, multi-dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays.&#8221;<\/p>\n<p>In addition to introducing a wealth of highly-performant new data structures and mathematical functions, NumPy changed the data programming metaphor in Python from procedural to specification. In Part 1, I detail looping-like code for building the final lists; in Part 2, I pretty much simply invoke array functions and structure subscripting to complete the tasks.<\/p>\n<p>Though I&#8217;m the first to acknowledge not being a NumPy expert, I had little trouble figuring out what to do with the help of<span>\u00a0<\/span><a href=\"https:\/\/stackoverflow.com\/\">stackoverflow<\/a>. Indeed, those familiar with the relatively recent<span>\u00a0<\/span><a href=\"https:\/\/pandas.pydata.org\/\">Pandas library for data analysis<\/a><span>\u00a0<\/span>will readily adapt to the foundational NumPy programming style. Core Python structures such as lists, dictionaries, comprehensions, and iterables serve primarily to feed the NumPy\/Pandas beasts.<\/p>\n<p>For the analysis that follows, I focus on performance of the Russell 3000 index, a competitor to the S&#038;P 500 and Wilshire 5000 for &#8220;measuring the market&#8221;. I first download two files &#8212; a year-to-date and a history, that provide final 3000 daily index levels starting in 2005. Attributes include index name, date, level without dividends reinvested, and level with dividends reinvested. I then wrangle the data using NumPy to get to the desired end state.<\/p>\n<p>The technology used for all three articles revolves on JupyterLab 0.32.1, Anaconda Python 3.6.5, NumPy 1.14.3, and Pandas 0.23.0.<\/p>\n<p>Read the remainder of the blog\u00a0<a href=\"https:\/\/storage.ning.com\/topology\/rest\/1.0\/file\/get\/969965586?profile=original\" target=\"_blank\" rel=\"noopener\">here.<\/a><\/p>\n<p><a href=\"https:\/\/storage.ning.com\/topology\/rest\/1.0\/file\/get\/969955376?profile=original\" target=\"_blank\" rel=\"noopener\"><\/a><\/p>\n<\/div>\n<p><a href=\"https:\/\/www.datasciencecentral.com\/xn\/detail\/6448529:BlogPost:799834\">Go to Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Author: steve miller Last week I posted the\u00a0first\u00a0of a three-part series on basic data programming with Python. For that article, I resurrected scripts written 10 [&hellip;] <span class=\"read-more-link\"><a class=\"read-more\" href=\"https:\/\/www.aiproblog.com\/index.php\/2019\/02\/06\/a-blast-from-python-past-part-2\/\">Read More<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":467,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[26],"tags":[],"_links":{"self":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/posts\/1686"}],"collection":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/comments?post=1686"}],"version-history":[{"count":0,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/posts\/1686\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/media\/464"}],"wp:attachment":[{"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/media?parent=1686"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/categories?post=1686"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aiproblog.com\/index.php\/wp-json\/wp\/v2\/tags?post=1686"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}