I have following problem:
My goal is to extract the unique member IDs of a data frame and have the as keys and also extract and sum up the transactions they have and have them as values.

*unique mem\_id = e.g. 70850441974905670928446*

*amount = 150.78*

*card\_members = df['unique\_mem\_id'].unique()*

EDIT:
Here an excerpt from the dataframe:

```
transaction_date    unique_mem_id   description amount
6/21/2014   7.08504E+22 HILLERS MARKET         NORTHVILLE   MI  61.72
6/22/2014   7.08504E+22 BUSCH'S #1032          PLYMOUTH     MI  25.48
6/23/2014   7.08504E+22 SPEEDWAY XXXXX 5 M     PLYMOUTH     MI  30.73
6/23/2014   7.08504E+22 HENDERSON GLASS INC    NOVI         MI  29.95
6/23/2014   7.08504E+22 HILLERS MARKET         NORTHVILLE   MI  59.6
6/23/2014   7.08504E+22 SPEEDWAY XXXXX 5 M     PLYMOUTH     MI  60.59
6/24/2014   7.08504E+22 BEACHWAY RESORT        SAUGATUCK    MI  1142.4
6/24/2014   7.08504E+22 PUMPERNICKELS EATERY   SAUGATUCK    MI  88.52
6/24/2014   7.08504E+22 DEMOND'S SUPER         DOUGLAS      MI  79.75
6/25/2014   7.08504E+22 DEMOND'S SUPER         DOUGLAS      MI  128.21

```

EDIT END

> 
> DatetimeIndex: 852 entries, 2014-06-21 to 2020-01-23 Data columns
>  (total 4 columns): # Column Non-Null Count Dtype 
> 
> 
> --- ------ -------------- -----  
> 
>  0 transaction\_date 852 non-null datetime64[ns]  
> 
>  1 unique\_mem\_id 852 non-null object  
> 
>  2 description 852 non-null object  
> 
>  3 amount 852 non-null float64  
> 
>  dtypes: datetime64ns, float64(1), object(2) memory usage: 53.3+ KB
> 
> 
> 

This is the dictionary I tried to code:

```
#test for transactions
from collections import defaultdict
transaction_dict = defaultdict(list)

for row in df_card.items():
    try:
        key = card_members
        value = df_card.amount
    except ValueError:
        continue

    transaction_dict[key] += value

print(transaction_dict)

```

THe error that comes up is: unhashable type: 'numpy.ndarray'

I have also tried df\_card.iterrows() but that also fails :(