I want to extracted date from description column to another column. But, I have countered some issues.
This is my DataFrame code:
df = pd.DataFrame({'description':['description: kartu debit 20/10 indomaretcipete r', 'description: tarikan atm 20/10',
'description: biaya adm', 'description: trsf e-banking db 18/10 wsid:23881 riri indah lestari',
'description: switching biaya txn di 008 komp clandak armori', 'description: switching withdrawal di 008 komp clandak imori',
'description: trsf e-banking db tanggal :13/10 13/10 wsid:269b1 dwi ayu mustika',
'description: trsf e-banking db 1310/ftva/ws269b100240/home credit - - 3800372540',
'description: kartu debit 09/10 starbuckspasaraya', 'description: byr via e-banking 13/09 wsid46841381200 telkomsel 081293112183 tezar alamsyah',
'description: switching db biaya txn ke 022 danabijak tezar albank centra', 'description: kartu debit spbu totalterogon'],
'label': ['minimarket', 'atm penarikan', 'administrasi', 'transfer', 'biaya', 'penarikan', 'personal',
'fintech', 'other', 'pulsa', 'biaya fintech', 'fuel']})
and this is the what I have been tried:
for date in df.description:
date = df.description
date = re.findall(r'\d{2}/\d{2}', date)
print(date)
But the output is TypeError: expected string or bytes-like object
df['description'].str.extractall(r'(\d{2}/\d{2})')..?dateto a pandas the Series 'description'. Don't do this - remove that line. Also I'd suggest giving your iterating variable a different name, instead of usingdatefor example just usefor description in df.description: ...thendate = re.findall(r'\d{2}/\d{2}', description)