Zack commited on
Commit
2320b32
·
1 Parent(s): df3beea

chore: drop missing values

Browse files
Files changed (2) hide show
  1. app.py +5 -1
  2. sales_hourly_short.csv +0 -29
app.py CHANGED
@@ -87,6 +87,9 @@ def clean_data(df):
87
 
88
  elif "Date_CY" in df.columns and "Hour" in df.columns and "Net_Sales_CY" in df.columns:
89
  # Convert "Date_CY" and "Hour" columns into datetime format
 
 
 
90
  df["timestamp"] = pd.to_datetime(df["Date_CY"]) + pd.to_timedelta(df["Hour"].astype(int), unit='h')
91
 
92
  # Handle the case where hour is 24
@@ -101,7 +104,8 @@ def clean_data(df):
101
 
102
  # Drop rows where 'value' is NaN
103
  df = df.dropna(subset=['value'])
104
- df = df.dropna(subset=['timestamp'])
 
105
 
106
  return df
107
 
 
87
 
88
  elif "Date_CY" in df.columns and "Hour" in df.columns and "Net_Sales_CY" in df.columns:
89
  # Convert "Date_CY" and "Hour" columns into datetime format
90
+
91
+ df = df.dropna(subset=['Date_CY', 'Hour', 'Net_Sales_CY'])
92
+
93
  df["timestamp"] = pd.to_datetime(df["Date_CY"]) + pd.to_timedelta(df["Hour"].astype(int), unit='h')
94
 
95
  # Handle the case where hour is 24
 
104
 
105
  # Drop rows where 'value' is NaN
106
  df = df.dropna(subset=['value'])
107
+
108
+ # df = df.dropna(subset=['timestamp'])
109
 
110
  return df
111
 
sales_hourly_short.csv CHANGED
@@ -1,33 +1,4 @@
1
  "Store","Date_CY","Date_PY","Hour","Destination","Gross_Sales_CY","Net_Sales_CY","Sales_Tax_CY","Discounts_CY","Voids_CY","Order_Ahead_Voids_CY","Tickets_CY","Tickets_NonZero_CY","Check_Calc_CY","Cash_Over_Short_CY","Outstanding_Checks_CY","Gross_Sales_PY","Net_Sales_PY","Sales_Tax_PY","Discounts_PY","Voids_PY","Order_Ahead_Voids_PY","Tickets_PY","Tickets_NonZero_PY","Check_Calc_PY","Cash_Over_Short_PY","Outstanding_Checks_PY"
2
- 71a6d9a4,"12/30/2019","12/31/2018",6,"Stall",36.65,27.67,2.28,8.98,0.00,0.00,7,7,3.9529,"","",6.18,6.18,0.51,0.00,0.00,0.00,1,1,6.1800,"",""
3
- 71a6d9a4,"12/30/2019","12/31/2018",7,"Stall",105.83,75.63,6.25,30.20,5.56,0.00,16,16,4.7269,"","",31.47,23.77,1.95,7.70,0.00,0.00,8,8,2.9713,"",""
4
- 71a6d9a4,"12/30/2019","12/31/2018",8,"Stall",89.76,64.40,5.30,25.36,0.00,0.00,17,17,3.7882,"","",68.99,57.15,4.72,11.84,0.00,0.00,11,11,5.1955,"",""
5
- 71a6d9a4,"12/30/2019","12/31/2018",9,"Stall",121.59,84.93,6.99,36.66,0.00,0.00,21,21,4.0443,"","",121.20,100.47,8.30,20.73,0.00,0.00,12,12,8.3725,"",""
6
- 71a6d9a4,"12/30/2019","12/31/2018",10,"Stall",126.08,81.18,6.70,44.90,0.00,0.00,16,14,5.7986,"","",69.04,61.52,5.07,7.52,0.00,0.00,11,11,5.5927,"",""
7
- 71a6d9a4,"12/30/2019","12/31/2018",11,"Stall",389.58,328.33,27.11,61.25,0.00,0.00,41,41,8.0080,"","",285.68,262.67,21.68,23.01,0.00,0.00,35,35,7.5049,"",""
8
- 71a6d9a4,"12/30/2019","12/31/2018",12,"Stall",392.78,346.69,28.64,46.09,0.00,0.00,39,39,8.8895,"","",309.62,284.56,23.50,25.06,0.00,0.00,33,33,8.6230,"",""
9
- 71a6d9a4,"12/30/2019","12/31/2018",13,"Stall",307.86,263.06,21.74,44.80,5.98,0.00,43,42,6.2633,"","",274.33,243.65,20.09,30.68,0.00,0.00,28,28,8.7018,"",""
10
- 71a6d9a4,"12/30/2019","12/31/2018",14,"Stall",218.68,177.14,14.62,41.54,0.00,0.00,31,31,5.7142,"","",239.77,192.18,15.89,47.59,0.00,0.00,36,36,5.3383,"",""
11
- 71a6d9a4,"12/30/2019","12/31/2018",15,"Stall",307.96,238.84,19.69,69.12,0.00,0.00,46,46,5.1922,"","",181.65,139.61,11.53,42.04,0.00,0.00,26,25,5.5844,"",""
12
- 71a6d9a4,"12/30/2019","12/31/2018",16,"Stall",309.47,268.40,22.18,41.07,0.00,0.00,38,38,7.0632,"","",204.37,171.14,14.11,33.23,0.00,0.00,27,27,6.3385,"",""
13
- 71a6d9a4,"12/30/2019","12/31/2018",17,"Stall",189.87,178.60,14.74,11.27,0.00,0.00,21,21,8.5048,"","",177.03,158.88,13.10,18.15,0.00,0.00,24,24,6.6200,"",""
14
- 71a6d9a4,"12/30/2019","12/31/2018",18,"Stall",281.92,254.54,21.01,27.38,0.00,0.00,28,28,9.0907,"","",173.75,156.66,12.91,17.09,7.78,0.00,23,22,7.1209,"",""
15
- 71a6d9a4,"12/30/2019","12/31/2018",19,"Stall",205.92,187.46,15.47,18.46,0.00,0.00,18,18,10.4144,"","",168.03,160.44,13.23,7.59,0.00,0.00,13,13,12.3415,"",""
16
- 71a6d9a4,"12/30/2019","12/31/2018",20,"Stall",97.72,94.06,7.76,3.66,0.00,0.00,13,13,7.2354,"","",182.28,170.74,14.07,11.54,0.00,0.00,21,21,8.1305,"",""
17
- 71a6d9a4,"12/30/2019","12/31/2018",21,"Stall",108.38,101.46,8.40,6.92,0.00,0.00,14,14,7.2471,"","",81.91,77.27,6.38,4.64,0.00,0.00,9,9,8.5856,"",""
18
- 71a6d9a4,"12/30/2019","12/31/2018",22,"Stall",63.25,57.23,4.73,6.02,0.00,0.00,9,9,6.3589,"","","","","","","","","","","","",""
19
- 71a6d9a4,"12/30/2019","12/31/2018",7,"Order Ahead",37.66,16.66,1.37,21.00,0.00,0.00,2,2,8.3300,"","","","","","","","","","","","",""
20
- 71a6d9a4,"12/30/2019","12/31/2018",8,"Order Ahead",2.49,1.24,0.10,1.25,0.00,0.00,1,1,1.2400,"","","","","","","","","","","","",""
21
- 71a6d9a4,"12/30/2019","12/31/2018",9,"Order Ahead",19.72,8.07,0.67,11.65,0.00,0.00,1,1,8.0700,"","","","","","","","","","","","",""
22
- 71a6d9a4,"12/30/2019","12/31/2018",10,"Order Ahead",23.31,12.46,1.02,10.85,0.00,0.00,3,3,4.1533,"","","","","","","","","","","","",""
23
- 71a6d9a4,"12/30/2019","12/31/2018",11,"Order Ahead",13.83,9.89,0.82,3.94,0.00,50.75,9,3,3.2967,"","","","","","","","","","","","",""
24
- 71a6d9a4,"12/30/2019","12/31/2018",12,"Order Ahead",10.36,5.31,0.44,5.05,0.00,0.00,4,4,1.3275,"","",12.55,9.10,0.75,3.45,0.00,0.00,3,3,3.0333,"",""
25
- 71a6d9a4,"12/30/2019","12/31/2018",13,"Order Ahead",21.33,17.30,1.43,4.03,0.00,0.00,3,3,5.7667,"","",7.56,3.57,0.29,3.99,0.00,0.00,1,1,3.5700,"",""
26
- 71a6d9a4,"12/30/2019","12/31/2018",14,"Order Ahead",22.61,12.57,1.04,10.04,0.00,0.00,3,3,4.1900,"","","","","","","","","","","","",""
27
- 71a6d9a4,"12/30/2019","12/31/2018",15,"Order Ahead",10.96,7.46,0.61,3.50,0.00,0.00,2,2,3.7300,"","","","","","","","","","","","",""
28
- 71a6d9a4,"12/30/2019","12/31/2018",16,"Order Ahead",16.54,10.89,0.90,5.65,0.00,0.00,3,3,3.6300,"","",6.17,4.03,0.33,2.14,0.00,6.17,2,1,4.0300,"",""
29
- 71a6d9a4,"12/30/2019","12/31/2018",17,"Order Ahead",59.91,54.06,4.46,5.85,0.00,0.00,5,5,10.8120,"","","","","","","","","","","","",""
30
- 71a6d9a4,"12/30/2019","12/31/2018",18,"Order Ahead",10.05,6.70,0.55,3.35,0.00,0.00,2,2,3.3500,"","","","","","","","","","","","",""
31
  71a6d9a4,"12/30/2019","12/31/2018",19,"Order Ahead","","","","","","","","","","","",10.75,9.41,0.78,1.34,0.00,0.00,1,1,9.4100,"",""
32
  71a6d9a4,"12/30/2019","12/31/2018",20,"Order Ahead",9.57,7.89,0.65,1.68,0.00,0.00,1,1,7.8900,"","","","","","","","","","","","",""
33
  71a6d9a4,"12/30/2019","12/31/2018",9,"Delivery",25.11,0.70,0.06,24.41,0.00,0.00,3,1,0.7000,"","",6.57,0.00,0.00,6.57,0.00,0.00,1,0,"","",""
 
1
  "Store","Date_CY","Date_PY","Hour","Destination","Gross_Sales_CY","Net_Sales_CY","Sales_Tax_CY","Discounts_CY","Voids_CY","Order_Ahead_Voids_CY","Tickets_CY","Tickets_NonZero_CY","Check_Calc_CY","Cash_Over_Short_CY","Outstanding_Checks_CY","Gross_Sales_PY","Net_Sales_PY","Sales_Tax_PY","Discounts_PY","Voids_PY","Order_Ahead_Voids_PY","Tickets_PY","Tickets_NonZero_PY","Check_Calc_PY","Cash_Over_Short_PY","Outstanding_Checks_PY"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  71a6d9a4,"12/30/2019","12/31/2018",19,"Order Ahead","","","","","","","","","","","",10.75,9.41,0.78,1.34,0.00,0.00,1,1,9.4100,"",""
3
  71a6d9a4,"12/30/2019","12/31/2018",20,"Order Ahead",9.57,7.89,0.65,1.68,0.00,0.00,1,1,7.8900,"","","","","","","","","","","","",""
4
  71a6d9a4,"12/30/2019","12/31/2018",9,"Delivery",25.11,0.70,0.06,24.41,0.00,0.00,3,1,0.7000,"","",6.57,0.00,0.00,6.57,0.00,0.00,1,0,"","",""