Spaces:
Sleeping
Sleeping
File size: 631 Bytes
8b0f491 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import pandas as pd
def clean_upi_data(df):
df['Date'] = pd.to_datetime(df['Date'], format="%d-%m-%Y")
df['Category'] = df['Description'].apply(lambda x: categorize_transaction(x))
return df
def categorize_transaction(description):
keywords = {
"Food": ["Zomato", "Swiggy", "Restaurant"],
"Shopping": ["Amazon", "Flipkart", "Myntra"],
"Bills": ["Electricity", "Gas", "Water"],
"Travel": ["Uber", "Ola", "IRCTC"],
}
for category, words in keywords.items():
if any(word.lower() in description.lower() for word in words):
return category
return "Other" |