Reputation: 586
I have a dataframe which I applied a groupby method call indexed off "Classification" and "Applying for FA?".
s = df.groupby("Classification")["Applying for FA?"].value_counts()
The following result is below
Classification Applying for FA?
FF N 172
Y 26
TR N 1
Y 1
Name: Applying for FA?, dtype: int64
Looking at the documentation for value_counts() it returns a series which is the object this information is stored. I want to access the particular values in the right column in order to do conditional probability.
For example, if I need P(FF | N), then my result is 172/frequency of N. How to I access the proper value through the two column names. Basically I am looking for something like
s["FF"]["N"] ... returns 172
s["FF"]["Y"] ... returns 26
Upvotes: 4
Views: 1904