Skip to main content

read_sql

orders = pd.read_sql_query(SQL, con=sql_conn)
order_daily = orders.copy()
order_daily['date_expected'] = order_daily['date_expected'].dt.normalize()
order_daily['date_expected'] = pd.to_datetime(order_daily.date_expected, format='%Y-%m-%d')

# Groups by date and UPC getting the sum of quanitity picked for each
# then resets index to fill in dates for all rows
tipd = order_daily.groupby(['UPC', 'date_expected']).sum().reset_index()
# Rearranging of columns to put UPC column first
tipd = tipd[['UPC','date_expected','quantity_picked']]
    
UPC date_expected  quantity_picked
0      0000000002554    2019-05-21              4.0
1      0000000002554    2019-05-24              2.0
2      0000000002554    2019-06-02              2.0
3      0000000002554    2019-06-17              2.0
4      0000000003082    2019-05-15              2.0
5      0000000003082    2019-05-16              2.0
6      0000000003082    2019-05-17              8.0
             ...           ...              ...
31588  0360600051715    2019-06-17              1.0
31589  0501072452748    2019-06-15              1.0
31590  0880100551750    2019-06-07              2.0
    
tipd = order_daily.groupby(['UPC', 'date_expected']).sum().reindex(idx, fill_value=0).reset_index()
# Rearranging of columns to put UPC column first
tipd = tipd[['UPC','date_expected','quantity_picked']]
# Viewing first 10 rows to check format of dataframe
print('Preview of Total per Item per Day')
print(tipd.iloc[0:10])
    
TypeError: Argument 'tuples' has incorrect type (expected numpy.ndarray, got DatetimeArray)