TODAY learn how to bring Drag & Drop to Dash with Dashboard Engine. 🌠 Sign up for the live event!

dcc.DatePickerRange returning numbers instead of dates

Am trying to make a dash dashboard with a datepickerrange but its returning numbers instead of dates, would really appreciate it if someone could let me know where i am going wrong thanks :slight_smile:

import pandas as pd
import dash
import dash_html_components as html
import dash_core_components as dcc
from datetime import datetime as dt

df = pd.read_csv(‘kaiterradf.csv’)
df[‘Time’] = pd.to_datetime(df[‘Time’])
df = df.set_index(‘Time’)

initialize the application

app = dash.Dash()

define the layout of the app

app.layout = html.Div([

# add a date range selector
dcc.DatePickerRange(
    id = 'my-date-picker-range',
    min_date_allowed = dt(2020, 12, 1),
    max_date_allowed = dt(2020, 12, 31),
    initial_visible_month = dt(2020, 12, 1)
),

dcc.Graph(id='myfig'),

])

@app.callback(
dash.dependencies.Output(‘myfig’, ‘figure’),
[dash.dependencies.Input(‘my-date-picker-range’, ‘start_date’),
dash.dependencies.Input(‘my-date-picker-range’, ‘end_date’)])
def update_output_div(start_date, end_date):
return {
‘data’: [go.Scatter(
x=df.loc[start_date:end_date],
y=df[‘Temperature’],
mode=‘lines’,

)]

}

app.run_server()

CSV file:

,index,Time,CO2,Humidity,PM10,PM2.5,Temperature,TVOC
0,0,2020-12-02 01:00:00+00:00,445.1,28.92,3.733,3.183,23.54,135.8
1,1,2020-12-02 02:00:00+00:00,424.5,28.21,3.2,2.833,23.44,129
2,2,2020-12-02 03:00:00+00:00,418.1,27.8,3.583,3.067,23.4,234.7
3,3,2020-12-02 04:00:00+00:00,415.3,27.5,3.541,3.033,23.39,179.4
4,4,2020-12-02 05:00:00+00:00,415,27.37,3.15,2.767,23.38,93.37
5,5,2020-12-02 06:00:00+00:00,425.3,27.4,3.6,3.333,23.35,52.4
6,6,2020-12-02 07:00:00+00:00,432,27.32,4.183,3.683,23.33,57.85
7,7,2020-12-02 08:00:00+00:00,439.2,27.22,4.267,3.883,23.3,44.63
8,8,2020-12-02 09:00:00+00:00,457.4,27.2,4.45,3.967,23.37,53.12
9,9,2020-12-02 10:00:00+00:00,512.5,27.35,5.417,4.8,23.55,166.8
10,10,2020-12-02 11:00:00+00:00,530.9,27.36,6.117,5.533,23.71,181.2
11,11,2020-12-02 12:00:00+00:00,524.1,27.11,5.883,5.317,23.89,127.9
12,12,2020-12-02 13:00:00+00:00,519.2,26.84,6.262,5.852,24.04,125.4
13,13,2020-12-02 14:00:00+00:00,514.1,26.91,7.217,6.567,24.14,238.1
14,14,2020-12-02 15:00:00+00:00,531.9,27.28,8.067,7.2,24.15,2544
15,15,2020-12-02 16:00:00+00:00,531.5,27.89,8.6,7.817,24.11,339.4
16,16,2020-12-02 17:00:00+00:00,523.7,28.41,9.217,8.083,24.14,219.8
17,17,2020-12-02 18:00:00+00:00,507.7,28.85,8.617,7.917,24.12,234.1
18,18,2020-12-02 19:00:00+00:00,479.5,29.42,8.617,8.017,24.03,145.1
19,19,2020-12-02 20:00:00+00:00,449.9,30.02,8.574,7.885,23.92,100.2
20,20,2020-12-02 21:00:00+00:00,442.3,30.46,9.617,8.883,23.86,117.2
21,21,2020-12-02 22:00:00+00:00,439.7,30.66,9.617,8.9,23.84,122.2
22,22,2020-12-02 23:00:00+00:00,432.6,30.79,8.517,8,23.79,97.73
23,23,2020-12-03 00:00:00+00:00,427.1,30.86,8,7.4,23.74,66.67
24,24,2020-12-03 01:00:00+00:00,420,30.59,7,6.283,23.71,40.47
25,25,2020-12-03 02:00:00+00:00,414.4,30.27,5.917,5.383,23.65,19.68
26,26,2020-12-03 03:00:00+00:00,408.8,29.71,4.333,3.917,23.61,8.717
27,27,2020-12-03 04:00:00+00:00,405.8,29.41,3.533,3,23.55,7.717
28,28,2020-12-03 05:00:00+00:00,401.7,29.21,2.705,2.23,23.52,7.016
29,29,2020-12-03 06:00:00+00:00,398.8,29.07,1.817,1.267,23.51,7.733
30,30,2020-12-03 07:00:00+00:00,400.6,28.94,1.217,0.7667,23.49,9.55
31,31,2020-12-03 08:00:00+00:00,401.8,28.92,1.167,0.7,23.46,12.33
32,32,2020-12-03 09:00:00+00:00,402.9,29.14,0.6833,0.35,23.44,17.58
33,33,2020-12-03 10:00:00+00:00,404.7,29.5,1,0.5,23.42,28.73
34,34,2020-12-03 11:00:00+00:00,403.4,29.76,0.3167,0.1667,23.43,40.68
35,35,2020-12-03 12:00:00+00:00,401.1,30.15,0.3,0.08333,23.41,54.15
36,36,2020-12-03 13:00:00+00:00,401.9,30.61,0.4667,0.1,23.41,68.72
37,37,2020-12-03 14:00:00+00:00,399.4,30.91,0.5574,0.2787,23.43,78.13
38,38,2020-12-03 15:00:00+00:00,401.8,31.25,0.75,0.4833,23.42,89.48
39,39,2020-12-03 16:00:00+00:00,403.6,31.59,0.8,0.5,23.42,99.15
40,40,2020-12-03 17:00:00+00:00,405.9,31.5,0.3333,0.05,23.43,111.9
41,41,2020-12-03 18:00:00+00:00,411.6,31.2,0.2833,0.1167,23.41,112.9
42,42,2020-12-03 19:00:00+00:00,417.5,31.05,1.033,0.8,23.37,115.1
43,43,2020-12-03 20:00:00+00:00,418.4,30.84,2.45,2.183,23.36,121.3
44,44,2020-12-03 21:00:00+00:00,417.4,30.51,3.95,3.633,23.35,121.4
45,45,2020-12-03 22:00:00+00:00,412.9,30.25,4.717,4.117,23.4,119.3
46,46,2020-12-03 23:00:00+00:00,406,30.13,3.18,2.902,23.4,95.38
47,47,2020-12-04 00:00:00+00:00,411.6,30.08,3.633,3.367,23.45,171.6
48,48,2020-12-04 01:00:00+00:00,414.7,29.98,4.65,4.35,23.47,348.1
49,49,2020-12-04 02:00:00+00:00,406,29.91,3.7,3.5,23.41,245
50,50,2020-12-04 03:00:00+00:00,399.1,30.07,2.7,2.517,23.37,126.5
51,51,2020-12-04 04:00:00+00:00,391.3,30.01,1.233,1.15,23.31,90.58
52,52,2020-12-04 05:00:00+00:00,388.1,29.88,0.75,0.6167,23.24,51.27
53,53,2020-12-04 06:00:00+00:00,389.8,29.7,1.183,0.95,23.14,30.67
54,54,2020-12-04 07:00:00+00:00,393.2,29.42,1.55,1.517,23.09,20.37
55,55,2020-12-04 08:00:00+00:00,397.2,29.08,1.115,1.082,23.09,28.49
56,56,2020-12-04 09:00:00+00:00,400.9,28.76,0.75,0.65,23.06,39.98
57,57,2020-12-04 10:00:00+00:00,400.7,28.59,0.4667,0.3833,23.06,62.88
58,58,2020-12-04 11:00:00+00:00,400.8,28.77,0.4667,0.1833,23.06,90.9
59,59,2020-12-04 12:00:00+00:00,400.3,28.79,0.4167,0.2667,23.02,69.18
60,60,2020-12-04 13:00:00+00:00,401.3,29.02,0.6833,0.4,23.04,69.83
61,61,2020-12-04 14:00:00+00:00,400.7,29.05,0.7667,0.4333,23.14,71.3
62,62,2020-12-04 15:00:00+00:00,400,28.59,1.217,0.7167,23.18,69.02
63,63,2020-12-04 16:00:00+00:00,401.4,28.01,1.1,0.8167,23.13,55.15
64,64,2020-12-04 17:00:00+00:00,404.6,27.48,1.541,1.246,23.06,54.74
65,65,2020-12-04 18:00:00+00:00,409.7,27.16,2.067,1.7,22.99,57.18
66,66,2020-12-04 19:00:00+00:00,413.4,27.12,3.183,2.85,22.95,60.92
67,67,2020-12-04 20:00:00+00:00,410.6,26.98,4.417,3.883,22.93,67.93
68,68,2020-12-04 21:00:00+00:00,407,26.77,5.467,4.85,22.91,63.58
69,69,2020-12-04 22:00:00+00:00,403.6,26.42,6.217,5.45,22.89,44.8
70,70,2020-12-04 23:00:00+00:00,401.7,26.04,4.583,4.05,22.88,31.43
71,71,2020-12-05 00:00:00+00:00,403.6,25.76,3.55,3.133,22.91,29.55
72,72,2020-12-05 01:00:00+00:00,402.9,25.55,3.117,2.633,22.94,28.35
73,73,2020-12-05 02:00:00+00:00,399.1,25.4,2.984,2.803,22.96,25.97
74,74,2020-12-05 03:00:00+00:00,395.1,25.38,2.15,1.717,22.98,21.7
75,75,2020-12-05 04:00:00+00:00,392.1,25.54,0.8167,0.4167,22.99,19.1
76,76,2020-12-05 05:00:00+00:00,389.4,25.65,0.2167,0.06667,23.01,11.73
77,77,2020-12-05 06:00:00+00:00,390.9,25.85,0.2167,0.03333,23,9.417
78,78,2020-12-05 07:00:00+00:00,391.2,26.13,0.3167,0.1,22.98,10.57
79,79,2020-12-05 08:00:00+00:00,392.1,26.54,0.3333,0.08333,22.98,27.33
80,80,2020-12-05 09:00:00+00:00,395.6,26.91,0.3,0.1167,23.02,59.22
81,81,2020-12-05 10:00:00+00:00,397.7,27.25,0.7833,0.3667,23.15,58.95
82,82,2020-12-05 11:00:00+00:00,400.3,26.77,0.8197,0.4098,23.65,56.02
83,83,2020-12-05 12:00:00+00:00,398.3,25.66,0.7667,0.4333,24.85,95.72
84,84,2020-12-05 13:00:00+00:00,396.9,24.93,0.8,0.3667,25.47,109.6
85,85,2020-12-05 14:00:00+00:00,397.9,25.17,1,0.6833,24.94,97.48
86,86,2020-12-05 15:00:00+00:00,403.2,25.38,1.117,0.8667,24.5,94
87,87,2020-12-05 16:00:00+00:00,407.3,25.63,2.9,2.45,24.17,94.47
88,88,2020-12-05 17:00:00+00:00,413.6,25.74,2.467,2.167,23.9,98.45
89,89,2020-12-05 18:00:00+00:00,416.8,25.91,2.983,2.85,23.72,106.6
90,90,2020-12-05 19:00:00+00:00,425.9,26.14,6.066,5.623,23.6,211.4
91,91,2020-12-05 20:00:00+00:00,431.1,26.37,9.717,8.867,23.55,284.2
92,92,2020-12-05 21:00:00+00:00,431.3,26.5,10.48,9.983,23.53,559.4
93,93,2020-12-05 22:00:00+00:00,424.4,26.61,12.65,11.87,23.48,692.9
94,94,2020-12-05 23:00:00+00:00,422.1,26.56,9.617,8.933,23.4,825.4
95,95,2020-12-06 00:00:00+00:00,418.7,26.69,6.967,6.5,23.33,563.2
96,96,2020-12-06 01:00:00+00:00,416.4,26.55,7.1,6.75,23.32,544.4
97,97,2020-12-06 02:00:00+00:00,411.8,26.49,5.85,5.367,23.31,545.6
98,98,2020-12-06 03:00:00+00:00,408.3,26.41,5.016,4.656,23.3,500
99,99,2020-12-06 04:00:00+00:00,405.6,26.4,4.6,4.217,23.28,524.9
100,100,2020-12-06 05:00:00+00:00,404.9,26.45,4.633,4.317,23.23,576.1
101,101,2020-12-06 06:00:00+00:00,405.3,26.3,5.05,4.65,23.17,472
102,102,2020-12-06 07:00:00+00:00,404.6,26.25,4.85,4.617,23.13,478.4
103,103,2020-12-06 08:00:00+00:00,405.9,26.24,4.583,4.45,23.13,571.6
104,104,2020-12-06 09:00:00+00:00,408.6,26.32,5.083,4.817,23.14,461
105,105,2020-12-06 10:00:00+00:00,410.6,26.47,4.533,4.267,23.21,527.2
106,106,2020-12-06 11:00:00+00:00,411.3,26.62,4.557,4.131,23.28,491.5
107,107,2020-12-06 12:00:00+00:00,412.6,26.4,4.9,4.617,23.43,336.7
108,108,2020-12-06 13:00:00+00:00,412.8,26.57,4.45,4.083,23.51,493.9
109,109,2020-12-06 14:00:00+00:00,413.8,26.52,4.967,4.433,23.56,449.3
110,110,2020-12-06 15:00:00+00:00,414.7,26.6,5.767,5.5,23.57,341.5
111,111,2020-12-06 16:00:00+00:00,418.3,26.8,7.25,6.717,23.54,245.1
112,112,2020-12-06 17:00:00+00:00,434.3,27.06,6.35,5.917,23.47,271.8
113,113,2020-12-06 18:00:00+00:00,466.5,27.32,6.833,6.383,23.42,396.4
114,114,2020-12-06 19:00:00+00:00,458.5,27.29,11.15,10.45,23.27,536.9
115,115,2020-12-06 20:00:00+00:00,440.7,27.12,12.75,12.05,23.08,457.4
116,116,2020-12-06 21:00:00+00:00,434.2,26.96,13.12,12.45,22.97,260.2
117,117,2020-12-06 22:00:00+00:00,430.1,26.88,14.75,13.88,22.96,224.8
118,118,2020-12-06 23:00:00+00:00,429.6,26.8,12.47,12,22.92,102.4
119,119,2020-12-07 00:00:00+00:00,428.3,26.85,10.57,10.07,22.81,33.93
120,120,2020-12-07 01:00:00+00:00,424.9,26.9,8.233,7.683,22.77,5.783
121,121,2020-12-07 02:00:00+00:00,420.6,26.83,6.085,5.746,22.73,5.22
122,122,2020-12-07 03:00:00+00:00,418.9,26.76,5.317,5.017,22.71,68.07
123,123,2020-12-07 04:00:00+00:00,417.6,26.69,4.475,4.246,22.66,73.67
124,124,2020-12-07 05:00:00+00:00,417.9,26.56,3.533,3.317,22.59,43.02
125,125,2020-12-07 06:00:00+00:00,420.5,26.49,2.85,2.817,22.58,233
126,126,2020-12-07 07:00:00+00:00,418,26.44,2.883,2.717,22.55,181.1
127,127,2020-12-07 08:00:00+00:00,420.5,26.45,2.633,2.517,22.53,120.7
128,128,2020-12-07 09:00:00+00:00,444.6,26.61,3.717,3.383,22.64,128.5
129,129,2020-12-07 10:00:00+00:00,542.7,27.36,4.9,4.5,22.81,309
130,130,2020-12-07 11:00:00+00:00,633,27.73,6.35,5.817,23.02,495
131,131,2020-12-07 12:00:00+00:00,631.5,27.75,7,6.541,23.29,576
132,132,2020-12-07 13:00:00+00:00,618.7,27.84,7.867,7.35,23.47,736.3
133,133,2020-12-07 14:00:00+00:00,629.5,28.24,11.47,10.87,23.49,645.1
134,134,2020-12-07 15:00:00+00:00,644.8,28.35,12.08,11.45,23.56,691.4
135,135,2020-12-07 16:00:00+00:00,648.1,28.37,13.03,12.4,23.58,524.5
136,136,2020-12-07 17:00:00+00:00,662.8,28.42,14.03,13.43,23.59,1821
137,137,2020-12-07 18:00:00+00:00,616.6,28.47,16,15.13,23.54,1116
138,138,2020-12-07 19:00:00+00:00,523.1,28.13,18.07,17.08,23.36,616.6
139,139,2020-12-07 20:00:00+00:00,474.7,27.98,17.39,16.52,23.17,327
140,140,2020-12-07 21:00:00+00:00,454.7,27.89,15.87,15.05,22.92,178.9
141,141,2020-12-07 22:00:00+00:00,445.9,27.67,13.67,12.82,23,160.8
142,142,2020-12-07 23:00:00+00:00,457.8,27.59,12,11.27,22.95,188.2
143,143,2020-12-08 00:00:00+00:00,453.7,27.39,9.467,9.117,22.99,133.9
144,144,2020-12-08 01:00:00+00:00,452,27.26,9.917,9.317,23.02,88.18
145,145,2020-12-08 02:00:00+00:00,448.9,27.14,9.4,8.967,22.98,65.07
146,146,2020-12-08 03:00:00+00:00,452.8,27.12,10.58,10,22.96,63.15
147,147,2020-12-08 04:00:00+00:00,460.6,27.12,11.77,11.1,22.96,114
148,148,2020-12-08 05:00:00+00:00,463.2,27.1,12.13,11.34,22.97,100.5
149,149,2020-12-08 06:00:00+00:00,473.3,27.1,9.95,9.55,22.97,82.32
150,150,2020-12-08 07:00:00+00:00,474.8,27.14,8.917,8.367,22.93,71.73
151,151,2020-12-08 08:00:00+00:00,469.3,26.81,8.383,8.067,22.98,73.35
152,152,2020-12-08 09:00:00+00:00,496.4,27.21,10.63,10.02,22.76,124
153,153,2020-12-08 10:00:00+00:00,593.6,27.86,11.83,11.08,22.85,394.7
154,154,2020-12-08 11:00:00+00:00,655.5,27.4,10.47,9.78,23.29,373.1
155,155,2020-12-08 12:00:00+00:00,644.6,29.22,10.55,9.633,22.32,366.7
156,156,2020-12-08 13:00:00+00:00,624.6,29.02,11.48,10.7,22.69,268.1
157,157,2020-12-08 14:00:00+00:00,616.3,29.17,11.53,10.67,22.77,314.4
158,158,2020-12-08 15:00:00+00:00,636.7,29.84,10.67,9.75,22.59,512.3
159,159,2020-12-08 16:00:00+00:00,655.8,30.26,8.717,7.933,22.52,669.3
160,160,2020-12-08 17:00:00+00:00,655.4,30.44,9.117,8.533,22.46,604.1
161,161,2020-12-08 18:00:00+00:00,660.3,30.7,11.85,10.92,22.37,714.5
162,162,2020-12-08 19:00:00+00:00,595,30.45,13.92,13.02,22.28,459.8
163,163,2020-12-08 20:00:00+00:00,518.9,30.11,14.2,13.42,22.06,211.1
164,164,2020-12-08 21:00:00+00:00,478.1,30.02,14.27,13.28,21.85,137.2
165,165,2020-12-08 22:00:00+00:00,455.3,29.98,13.6,12.48,21.74,92.35
166,166,2020-12-08 23:00:00+00:00,475.3,30.78,12.58,11.73,21.62,150.1
167,167,2020-12-09 00:00:00+00:00,482.9,32.21,9.983,9.167,21.53,163
168,168,2020-12-09 01:00:00+00:00,440.5,31.83,7.344,6.902,21.42,80.59
169,169,2020-12-09 02:00:00+00:00,427,31.95,6.6,6.083,21.32,45.25
170,170,2020-12-09 03:00:00+00:00,421.6,32.16,6.083,5.567,21.26,27.17
171,171,2020-12-09 04:00:00+00:00,418.3,32.34,4.967,4.333,21.25,15.97
172,172,2020-12-09 05:00:00+00:00,414,32.46,3.317,2.783,21.23,11.22
173,173,2020-12-09 06:00:00+00:00,419.3,32.52,2.467,1.867,21.21,7.617
174,174,2020-12-09 07:00:00+00:00,421.1,32.51,2.183,1.6,21.22,14.38
175,175,2020-12-09 08:00:00+00:00,422.7,32.47,2.5,1.733,21.23,36.25
176,176,2020-12-09 09:00:00+00:00,431.3,32.52,2.607,2.016,21.2,52.85
177,177,2020-12-09 10:00:00+00:00,526.3,33.51,2.667,2.017,21.38,295.7
178,178,2020-12-09 11:00:00+00:00,575.5,33.53,3.217,2.367,21.65,224.1
179,179,2020-12-09 12:00:00+00:00,576.6,33.17,3.5,2.8,21.82,224.7
180,180,2020-12-09 13:00:00+00:00,571.4,32.93,3.783,3.05,21.85,148.2
181,181,2020-12-09 14:00:00+00:00,526.8,32.62,4.35,3.667,21.79,141.2
182,182,2020-12-09 15:00:00+00:00,516.1,32.47,4.767,3.783,21.67,385.1
183,183,2020-12-09 16:00:00+00:00,563.1,32.56,5.2,4.483,21.61,395.4
184,184,2020-12-09 17:00:00+00:00,589.1,32.63,6.557,5.738,21.58,421.3
185,185,2020-12-09 18:00:00+00:00,600.7,32.78,7.733,6.783,21.56,451.6
186,186,2020-12-09 19:00:00+00:00,533.3,32.45,8.733,7.733,21.47,278.7
187,187,2020-12-09 20:00:00+00:00,488.2,32.11,9.3,8.35,21.36,234.6
188,188,2020-12-09 21:00:00+00:00,457.3,31.81,8.567,7.817,21.19,157.3
189,189,2020-12-09 22:00:00+00:00,438.6,31.6,8.45,7.767,21,96.65
190,190,2020-12-09 23:00:00+00:00,426.5,31.52,6.483,5.817,20.9,51.55