Hello all! I’m trying to use plotly to create a scatter plot, but it seems like I’m getting no output and I’m not sure what’s happening. This is the code I currently have -
#New column with hour rounded
df[‘hour’] = df[‘p_time’].dt.floor(‘h’)
#New column with day rounded
df[‘day’] = df[‘p_time’].dt.ceil(‘d’)
#Counting number of riders per hour
hour_counts = {}
for row in df[‘hour’]:
if row in hour_counts:
hour_counts[row] = hour_counts[row] + 1
else:
hour_counts[row] = 1
#Counting number of riders per day
day_counts = {}
for row in df[‘day’]:
if row in day_counts:
day_counts[row] = day_counts[row] + 1
else:
day_counts[row] = 1
count = Scatter(
x = day_counts.keys(),
y = day_counts.values(),
name = “Number of Riders”,
line = dict(color = ‘#17BECF’),
opacity = 0.8)
data = [count]
layout = dict(
title=‘Time Series with Rangeslider’,
xaxis=dict(
rangeselector=dict(
buttons=list([
dict(count=1,
label=‘1d’,
step=‘day’,
stepmode=‘backward’),
dict(count=6,
label=‘6d’,
step=‘day’,
stepmode=‘backward’),
dict(step=‘all’)
])
),
rangeslider=dict(),
type=‘date’
)
)
fig = dict(data=data, layout=layout)
iplot(fig)
Not sure what’s happening here, but when I try to print data, I get nothing, so it seems like it’s not reading my x and y values? Any advice? Sorry, I’m fairly new to python!