Spaces:
Runtime error
Runtime error
Zack
commited on
Commit
·
2c107c1
1
Parent(s):
62b762e
fix: Cleaning data
Browse files
app.py
CHANGED
|
@@ -80,13 +80,9 @@ def clean_data(df):
|
|
| 80 |
# Rename column
|
| 81 |
df.rename(columns={"Hourly_Labor_Hours_Total": "value"}, inplace=True)
|
| 82 |
|
| 83 |
-
elif "Date_CY" in df.columns and "
|
| 84 |
-
# Convert "
|
| 85 |
-
df["timestamp"] = pd.to_datetime(df["Date_CY"]
|
| 86 |
-
|
| 87 |
-
# Handle the case where hour is 24
|
| 88 |
-
df.loc[df["timestamp"].dt.hour == 24, "timestamp"] = df["timestamp"] + pd.DateOffset(days=1)
|
| 89 |
-
df["timestamp"] = df["timestamp"].dt.floor('h')
|
| 90 |
|
| 91 |
# Keep only necessary columns
|
| 92 |
df = df[["timestamp", "Net_Sales_CY"]]
|
|
|
|
| 80 |
# Rename column
|
| 81 |
df.rename(columns={"Hourly_Labor_Hours_Total": "value"}, inplace=True)
|
| 82 |
|
| 83 |
+
elif "Date_CY" in df.columns and "Store" in df.columns and "Net_Sales_CY" in df.columns:
|
| 84 |
+
# Convert "Date_CY" and "Store" columns into datetime format
|
| 85 |
+
df["timestamp"] = pd.to_datetime(df["Date_CY"] + " " + df["Store"].astype(str) + ":00:00")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
# Keep only necessary columns
|
| 88 |
df = df[["timestamp", "Net_Sales_CY"]]
|