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>you can use the groupby method such has:</p>

<pre><code>grouped_df = df.groupby('Part Number')
</code></pre>

<p>and then you can access the df of a certain part number and set the index easily such has:</p>

<pre><code>new_df = grouped_df.get_group('THEPARTNUMBERYOUWANT').set_index('Calendar Year/Month')
</code></pre>

<p>if you only want the 2 columns you can do:</p>

<pre><code>print new_df[['Sales', 'Inventory']]]
</code></pre>

python pandas dataframe time-series