Spaces:
Runtime error
Runtime error
Zack
commited on
Commit
·
836879e
1
Parent(s):
2637471
feat: Clean and add sales_hourly_short.csv
Browse files- app.py +15 -1
- sales_hourly_short.csv +0 -0
app.py
CHANGED
@@ -80,6 +80,20 @@ def clean_data(df):
|
|
80 |
# Rename column
|
81 |
df.rename(columns={"Hourly_Labor_Hours_Total": "value"}, inplace=True)
|
82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
return df
|
84 |
|
85 |
else:
|
@@ -116,7 +130,7 @@ iface = gr.Interface(
|
|
116 |
fn=master,
|
117 |
inputs=gr.inputs.File(label="CSV File"),
|
118 |
outputs=outputs,
|
119 |
-
examples=["art_daily_jumpsup.csv","labor_hourly_short.csv"],
|
120 |
title="Timeseries Anomaly Detection Using an Autoencoder",
|
121 |
description="Anomaly detection of timeseries data."
|
122 |
)
|
|
|
80 |
# Rename column
|
81 |
df.rename(columns={"Hourly_Labor_Hours_Total": "value"}, inplace=True)
|
82 |
|
83 |
+
elif "Date_CY" in df.columns and "Hour" in df.columns and "Net_Sales_CY" in df.columns:
|
84 |
+
# Convert "Date" and "Hour" columns into datetime format
|
85 |
+
df["timestamp"] = pd.to_datetime(df["Date_CY"]) + pd.to_timedelta(df["Hour"].astype(int), unit='h')
|
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"]]
|
93 |
+
|
94 |
+
# Rename column
|
95 |
+
df.rename(columns={"Net_Sales_CY": "value"}, inplace=True)
|
96 |
+
|
97 |
return df
|
98 |
|
99 |
else:
|
|
|
130 |
fn=master,
|
131 |
inputs=gr.inputs.File(label="CSV File"),
|
132 |
outputs=outputs,
|
133 |
+
examples=["art_daily_jumpsup.csv","labor_hourly_short.csv, sales_hourly_short.csv"],
|
134 |
title="Timeseries Anomaly Detection Using an Autoencoder",
|
135 |
description="Anomaly detection of timeseries data."
|
136 |
)
|
sales_hourly_short.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|