I have a dataset where for some people credit card application is accepted while for others it is declined.
I want to divide the dataset into two datasets; one for which all the credit cards are accepted(card='yes') and the other for which all the credit cards are declined(card='no').
The dataset is as shown below:

How can I do that?
One option is to perform a groupby operation inside a dict comprehension. This has the added benefit of working for an arbitrary number of categories.
dfs_by_card = {
accepted: sub_df
for accepted, sub_df in credit5.groupby("card")
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With