0
$\begingroup$

I want to filter a pandas dataframe based on the id of the row. The id is a sequence of patient names. For example, I have columns in this format:

 ID | A | B 

And the id values looks like TCGA-A6-6653-01Z-00-DX1.e130666d-2681-4382-9e7a-4a4d27cb77a4 but multiple repeating ones. I want to group the unique ids and do a mean operation on A and B.

Can anyone guide me?
Thanks

$\endgroup$

1 Answer 1

1
$\begingroup$

You can just groupby id and do mean for the remaining columns.

df.groupby('id').mean()
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.