0

It is like I have a data frame. I groupby the ['ID', 'disease'] , in disease column there are more than 2 diseases I want to know how to get the frequency of combination of disease.

id        disease
1         Aids
ADHD
2         Something
Aids

For example how do I know how many ID has disease combination of Aids and ADHD

I am expecting like getting a new column to have the frequency on.

mozway
  • 194,879
  • 13
  • 39
  • 75
P.P
  • 1
  • 1
  • Your formatting is unclear, please fix and give more details if the duplicate is not what you need – mozway Mar 31 '22 at 09:24
  • Hi, id disease 1 A B 2 B C This is the format, it pretty much is I want to know how many times, disease A and B happened to a patient – P.P Apr 01 '22 at 01:27
  • Ok, I just realized the spaces doesnt work so good. But for example, patient ID 1 has two disease in two rows of data, such as A and B. I want to know how I can calculate the patients that has disease A and B. – P.P Apr 01 '22 at 01:30
  • Please read [this](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) carefully, improve your question accordingly, and we'll see how we can answer your question. – mozway Apr 01 '22 at 01:42

0 Answers0