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