Q:

Extracting combination of multiple columns from pandas dataframe

I have the foll. dataframe in pandas:
df

DAY   YEAR    REGION   VALUE
  1   2000     A         12
  2   2000     A         10
  3   2000     A         13
  6   2000     A         15
  1   2001     A         3
  2   2001     A         40
  3   2001     A         83
  4   2001     A         95
  1   2000     B         124
  3   2000     B         102
  5   2000     B         131
  8   2000     B         150
  1   2001     B         30
  5   2001     B         4
  8   2001     B         8
  9   2001     B         12

How can I create a new dataframe which contains unique combinations of YEAR and REGION in result? Result shoul look like this:
YEAR   REGION
2000    A
2001    A
2000    B
2001    B

A:

You can sub-select from your df and then call drop_duplicates:
In [16]:
df[['YEAR','REGION']].drop_duplicates()

Out[16]:
    YEAR REGION
0   2000      A
4   2001      A
8   2000      B
12  2001      B

