# 11.4 stack आणि unstack

Source: https://ravindrabagale.com/mr/datascience/ch11-reshape-and-wide-long-data/11-4-stack-unstack-brief.html
Language: mr (Marathi with English technical terms)

आधीच MultiIndex असेल तर stack/unstack उपयोगी पडतात:

s = pt.stack()          # Series with MultiIndex
back = s.unstack()      # toward wide again

stack नंतर MultiIndex असलेली Series मिळते. unstack ने पुन्हा wide दिशेने layout बदलतो.

Practice

wide ला melt करा. मग pivot_table मध्ये months rows म्हणून आणि cities columns म्हणून ठेवा. कोणत्या city-month चा GMV सर्वात जास्त आहे?
उत्तर तपासा
या sample मध्ये Pune–Oct चा GMV 220000 सर्वात जास्त आहे.

Recap

Analysis साठी long; माणसाला वाचायला grids साठी wide सोयीचा.

melt आणि pivot_table ही रोजची reshape जोडी.

Duplicate जोड्यांचं aggregation हवं असेल तर pivot_table वापरा.

आता EDA करूया.

रवींद्र बागले यांची tip

Reshape केल्यावर grain पुन्हा सांगा. “एक row म्हणजे city-month” असं स्पष्ट करता आलं पाहिजे.
