Python Pandas subset column x values based on unique values in column y
<p>I have a dataframe ( "df") equivalent to:</p>

<pre><code>   Cat   Data
    x    0.112
    x    0.112
    y    0.223
    y    0.223
    z    0.112
    z    0.112
</code></pre>

<p>In other words I have a category column and a data column, and the data values do not vary within values of the category column, but they may repeat themselves between different categories (i.e. the values in categories 'x' and 'z' are the same -- 0.112). This means that I need to select one data point from each category, rather than just subsetting on unique values of "Data". </p>

<p>The way I've done it is like this:</p>

<pre><code>    aLst = []
    bLst = []
    for i in df.index:
        if df.loc[i,'Cat'] not in aLst:
            aLst += [df.loc[i,'Cat']]
            bLst += [i]

    new_series = pd.Series(df.loc[bLst,'Data'])
</code></pre>

<p>Then I can do whatever I want with it. But the problem is this just seems like a clunky, un-pythonic way of doing things. Any suggestions? </p>