Extract series objects from Pandas DataFrame
<p>I have a dataframe with the columns</p>

<pre><code>['CPL4', 'Part Number', 'Calendar Year/Month', 'Sales', 'Inventory']
</code></pre>

<p>For each 'Part Number', 'Calendar Year/Month' will be unique on each Part Number.</p>

<p>I want to convert each part number to a univariate Series with 'Calendar Year/Month' as the index and either 'Sales' or 'Inventory' as the value.</p>

<p>How can I accomplish this using pandas built-in functions and not iterating through the dataframe manually?</p>

<p>In pandas this is called a MultiIndex. Try:</p>

<pre><code>import pandas as pd
df = pd.DataFrame(file, 
        index=['Part Number', 'Calendar Year/Month'], 
        columns = ['Sales', 'Inventory'])
</code></pre>

python pandas dataframe time-series