I have a pandas dataframe, which the following command works on:
house.groupby(['place_name'])['index_nsa'].agg(['first','last'])
It gives me what I want. Now I want to make a custom aggregation value that gives me the percentage change between the first and the last value.
I got an error for doing math on the values, so I assumed that I have to turn them into numbers.
house.groupby(['place_name'])['index_nsa'].agg({"change in %":[(int('last')-int('first')/int('first')]})
Unfortunately, I only get a syntax error on the last bracket, which I cannot seem to find the error.
Does someone see where I went wrong ?