I have pandas dataframe something like:

```
my_df = 

chr   PI
2     5
2     5
2     5
2     6
2     6
2     8
2     8
2     8
2     8
2     8
3     5
3     5
3     5
3     5
3     9
3     9
3     9
3     9
3     9
3     9
3     9
3     7
3     7
3     4
......
......

```

I want to convert it into new dataframe that contains new information on the dataframe, something like:

* chr: unique chromosomes
* unq\_PI : number of unique PIs within each chromosome
* PIs : list of "PI" values in that chromosome
* PI\_freq: length of each "PI" in the respective chromosome

**So, expected output would be:**

```
chr   unq_PI   PIs        PI_freq
2     3        5,6,8      3,2,5
3     4        5,9,7,4    4,7,2,1

```

I was thinking something like:

```
new_df = pd.DataFrame({'chr': my_df['chr'].unique(),
         'unq_PI': my_df('chr')['unq_PI'].nunique()),
         'PIs': .......................,
         'PI_freq': ..................})

The only code that works is for `chr` when used alone; any additional code just throws an error. How can I fix this?

```