{"id":647,"date":"2018-04-28T08:39:31","date_gmt":"2018-04-28T06:39:31","guid":{"rendered":"https:\/\/eaa-online.org\/arc\/blog\/blog\/pandas-and-hierarchical-indexing\/"},"modified":"2018-04-28T08:39:31","modified_gmt":"2018-04-28T06:39:31","slug":"pandas-and-hierarchical-indexing","status":"publish","type":"post","link":"https:\/\/eaa-online.org\/arc\/blog\/2018\/04\/28\/pandas-and-hierarchical-indexing\/","title":{"rendered":"Pandas and Hierarchical Indexing"},"content":{"rendered":"<div>\n\tPandas&#39; ability to index data offers additional power to the way you work with data. More interesting is pandas&#39; hierarchical indexing feature, it allows you to slice and dice data in convenient ways.<\/div>\n<div>\n\t&nbsp;<\/div>\n<div>\n\tPython and pandas allow you to manage data more efficiently and effectively than, say, Stata. One important problem with Stata is that you have all your data in one large file. As a result your work-file tends to grow, and thus gets messy.<\/div>\n<div>\n\t&nbsp;<\/div>\n<h4>\n\tEfficient data management<\/h4>\n<div>\n\t&nbsp;<\/div>\n<div>\n\tPython and pandas store data in various ways, e.g. in lists, tuples, sets, dictionaries, DataFrames and Series. This is super efficient: each data item can be stored in its most efficient form.<\/div>\n<div>\n\t&nbsp;<\/div>\n<div>\n\tOn top of that, for pandas there is <strong>indexing<\/strong> and <strong>hierarchical indexing<\/strong>. These features offer you the ability to focus on specific data sets within a single DataFrame. For example, your DataFrame may contain firm identification information, such as names and permcos, adjacent to numerical data. If you want to analyze the numbers, items such as names and permcos stand in the way. Hierarchical Indexing offers you a solution: you can set an index in such a way that your analysis only examines the numbers and ignore names and other non-numerical data.<\/div>\n<div>\n\t&nbsp;<\/div>\n<div>\n\tIndexing also allows you to quickly produce tables, (which then can be used as new DataFrames, etc).<\/div>\n<div>\n\t&nbsp;<\/div>\n<div>\n\tAn additional feature of indexing is that you can use it to merge files quickly.<\/div>\n<div>\n\t&nbsp;<\/div>\n<h4>\n\tThe examples here:<\/h4>\n<ul>\n<li>\n\t\t<a href=\"https:\/\/github.com\/blucap\/arc-pandas\/blob\/master\/use_index_creatively_ex_1.ipynb\" target=\"_blank\" rel=\"noopener\">Joining data made easy<\/a><\/li>\n<li>\n\t\t<a href=\"https:\/\/github.com\/blucap\/arc-pandas\/blob\/master\/use_index_creatively_ex_2.ipynb\" target=\"_blank\" rel=\"noopener\">Slicing data to find rows<\/a><\/li>\n<li>\n\t\t<a href=\"https:\/\/github.com\/blucap\/arc-pandas\/blob\/master\/use_index_creatively_ex_3.ipynb\" target=\"_blank\" rel=\"noopener\">Slicing to select columns<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Pandas&#39; ability to index data offers additional power to the way you work with data. More interesting is pandas&#39; hierarchical indexing feature, it allows you to slice and dice data in convenient ways. &nbsp; Python and pandas allow you to manage data more efficiently and effectively than, say, Stata. One important problem with Stata is [&hellip;]<\/p>\n","protected":false},"author":23,"featured_media":648,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0},"categories":[1],"tags":[4],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.12 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Pandas and Hierarchical Indexing - ARC<\/title>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Pandas and Hierarchical Indexing - ARC\" \/>\n<meta property=\"og:description\" content=\"Pandas&#039; ability to index data offers additional power to the way you work with data. More interesting is pandas&#039; hierarchical indexing feature, it allows you to slice and dice data in convenient ways. &nbsp; Python and pandas allow you to manage data more efficiently and effectively than, say, Stata. One important problem with Stata is [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/eaa-online.org\/arc\/blog\/2018\/04\/28\/pandas-and-hierarchical-indexing\/\" \/>\n<meta property=\"og:site_name\" content=\"ARC\" \/>\n<meta property=\"article:published_time\" content=\"2018-04-28T06:39:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/eaa-online.org\/app\/uploads\/sites\/3\/2018\/05\/hqdefault.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"480\" \/>\n\t<meta property=\"og:image:height\" content=\"360\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"MARTIEN LUBBERINK\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"MARTIEN LUBBERINK\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/eaa-online.org\/arc\/blog\/2018\/04\/28\/pandas-and-hierarchical-indexing\/\",\"url\":\"https:\/\/eaa-online.org\/arc\/blog\/2018\/04\/28\/pandas-and-hierarchical-indexing\/\",\"name\":\"Pandas and Hierarchical Indexing - ARC\",\"isPartOf\":{\"@id\":\"https:\/\/eaa-online.org\/arc\/#website\"},\"datePublished\":\"2018-04-28T06:39:31+00:00\",\"dateModified\":\"2018-04-28T06:39:31+00:00\",\"author\":{\"@id\":\"https:\/\/eaa-online.org\/arc\/#\/schema\/person\/d5611ef59a8723987b89e2177335aeac\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/eaa-online.org\/arc\/blog\/2018\/04\/28\/pandas-and-hierarchical-indexing\/\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/eaa-online.org\/arc\/#website\",\"url\":\"https:\/\/eaa-online.org\/arc\/\",\"name\":\"ARC\",\"description\":\"Advanced Resources Center\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/eaa-online.org\/arc\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/eaa-online.org\/arc\/#\/schema\/person\/d5611ef59a8723987b89e2177335aeac\",\"name\":\"MARTIEN LUBBERINK\",\"url\":\"https:\/\/eaa-online.org\/arc\/blog\/members\/23\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Pandas and Hierarchical Indexing - ARC","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"Pandas and Hierarchical Indexing - ARC","og_description":"Pandas&#39; ability to index data offers additional power to the way you work with data. More interesting is pandas&#39; hierarchical indexing feature, it allows you to slice and dice data in convenient ways. &nbsp; Python and pandas allow you to manage data more efficiently and effectively than, say, Stata. One important problem with Stata is [&hellip;]","og_url":"https:\/\/eaa-online.org\/arc\/blog\/2018\/04\/28\/pandas-and-hierarchical-indexing\/","og_site_name":"ARC","article_published_time":"2018-04-28T06:39:31+00:00","og_image":[{"width":480,"height":360,"url":"https:\/\/eaa-online.org\/app\/uploads\/sites\/3\/2018\/05\/hqdefault.jpg","type":"image\/jpeg"}],"author":"MARTIEN LUBBERINK","twitter_card":"summary_large_image","twitter_misc":{"Written by":"MARTIEN LUBBERINK","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/eaa-online.org\/arc\/blog\/2018\/04\/28\/pandas-and-hierarchical-indexing\/","url":"https:\/\/eaa-online.org\/arc\/blog\/2018\/04\/28\/pandas-and-hierarchical-indexing\/","name":"Pandas and Hierarchical Indexing - ARC","isPartOf":{"@id":"https:\/\/eaa-online.org\/arc\/#website"},"datePublished":"2018-04-28T06:39:31+00:00","dateModified":"2018-04-28T06:39:31+00:00","author":{"@id":"https:\/\/eaa-online.org\/arc\/#\/schema\/person\/d5611ef59a8723987b89e2177335aeac"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/eaa-online.org\/arc\/blog\/2018\/04\/28\/pandas-and-hierarchical-indexing\/"]}]},{"@type":"WebSite","@id":"https:\/\/eaa-online.org\/arc\/#website","url":"https:\/\/eaa-online.org\/arc\/","name":"ARC","description":"Advanced Resources Center","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/eaa-online.org\/arc\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/eaa-online.org\/arc\/#\/schema\/person\/d5611ef59a8723987b89e2177335aeac","name":"MARTIEN LUBBERINK","url":"https:\/\/eaa-online.org\/arc\/blog\/members\/23\/"}]}},"jetpack_featured_media_url":"https:\/\/eaa-online.org\/app\/uploads\/sites\/3\/2018\/05\/hqdefault.jpg","_links":{"self":[{"href":"https:\/\/eaa-online.org\/arc\/wp-json\/wp\/v2\/posts\/647"}],"collection":[{"href":"https:\/\/eaa-online.org\/arc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eaa-online.org\/arc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eaa-online.org\/arc\/wp-json\/wp\/v2\/users\/23"}],"replies":[{"embeddable":true,"href":"https:\/\/eaa-online.org\/arc\/wp-json\/wp\/v2\/comments?post=647"}],"version-history":[{"count":0,"href":"https:\/\/eaa-online.org\/arc\/wp-json\/wp\/v2\/posts\/647\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/eaa-online.org\/arc\/wp-json\/wp\/v2\/media\/648"}],"wp:attachment":[{"href":"https:\/\/eaa-online.org\/arc\/wp-json\/wp\/v2\/media?parent=647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eaa-online.org\/arc\/wp-json\/wp\/v2\/categories?post=647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eaa-online.org\/arc\/wp-json\/wp\/v2\/tags?post=647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}