I'm new to pandas and got stuck a bit. Can you help me?
I have a dataframe storing orders:
| item | store_status | customer_status |
|------|--------------|-----------------|
| A | 'dispatched' | 'received' |
| A | 'dispatched' | 'pending' |
| B | 'pending' | 'pending' |
| B | 'dispatched' | 'received' |
| B | 'dispatched' | 'pending' |
I want to create a new dataframe that shows what portion of each item is 'dispatched' and 'received'. So the result would be:
| item | dispatched_and_received |
|------|-------------------------|
| A | 0.5 |
| B | 0.33 |
I'm also interested in the portion of each item that is 'dispatched', regardless of the customer status and want to add it as a new column to this dataframe:
| item | dispatched_and_received | dispatched |
|------|-------------------------|------------|
| A | 0.5 | 1.00 |
| B | 0.33 | 0.66 |
Thank you!