original data frame:
| Date | Detail |
|---|---|
| 31/03/22 | I watch Netflix at home with my family 4 hours |
| 01/04/22 | I walk to the market for 3km and I spent 11.54 dollar |
| 02/04/22 | my dog bite me, I go to hospital, spend 29.99 dollar |
| 03/04/22 | I bought a game on steam 7 games spen 19.23 dollar |
result data frame:
| Date | Detail | Cost |
|---|---|---|
| 31/03/22 | I watch Netflix at home with my family 4 hours | 0 |
| 01/04/22 | I walk to the market for 3km and I spent 11.54 dollar | 11.54 |
| 02/04/22 | my dog bite me, I go to hospital, spend 29.99 dollar | 29.99 |
| 03/04/22 | I bought a game on steam 7 games spen 19.23 dollar | 19.23 |
Describe my question:
If Detail Column does not contain specific string which is begin with sp.. and end with dollar then value in Cost col equal zero.
If Detail Column does contain specific string which is begin with sp.. and end with dollar, then value in Cost col equal value in the middle of specific string which is begin with sp.. and end with dollar.
I try to use regex but it's got first int that contain in the col like
| 01/04/22 | I walk to the market for 3km and I spent 11.54 dollar| 3 |