Updating script/plotly_streamlit.py to correct pep8 violations
Used 'autopep8 --in-place --aggressive scripts/plotly_streamlit.py' as initial style fixes.
This commit is contained in:
@@ -42,6 +42,7 @@ def get_data(conn: Connection):
|
||||
df1 = pd.read_sql("SELECT * FROM detections", con=conn)
|
||||
return df1
|
||||
|
||||
|
||||
conn = get_connection(URI_SQLITE_DB)
|
||||
# Read in the cereal data
|
||||
# df = load_data()
|
||||
@@ -51,7 +52,6 @@ df2['DateTime']=pd.to_datetime(df2['Date'] + " " + df2['Time'])
|
||||
df2 = df2.set_index('DateTime')
|
||||
|
||||
|
||||
|
||||
# Filter on date range
|
||||
# Date as calendars
|
||||
# Start_Date = pd.to_datetime(st.sidebar.date_input('Which date do you want to start?', value = df2.index.min()))
|
||||
@@ -68,7 +68,6 @@ Date_Slider = st.slider('Date Range',
|
||||
)
|
||||
|
||||
|
||||
|
||||
filt = (df2.index >= pd.Timestamp(Date_Slider[0])) & (df2.index <= pd.Timestamp(Date_Slider[1] + timedelta(days=1)))
|
||||
df2 = df2[filt]
|
||||
|
||||
@@ -108,11 +107,13 @@ df_counts=df2[filt].resample('D').count()
|
||||
|
||||
fig = make_subplots(
|
||||
rows=3, cols=2,
|
||||
specs= [[{"type":"xy","rowspan":3}, {"type":"polar","rowspan":2}], [{"rowspan":1}, {"rowspan":1} ], [None, {"type":"xy","rowspan":1}]],
|
||||
specs=[[{"type": "xy", "rowspan": 3}, {"type": "polar", "rowspan": 2}], [
|
||||
{"rowspan": 1}, {"rowspan": 1}], [None, {"type": "xy", "rowspan": 1}]],
|
||||
subplot_titles=('<b>Top ' + str(top_N) + ' Species in Date Range ' + str(Date_Slider[0]) + ' to ' + str(Date_Slider[1]) + '</b>',
|
||||
'Total Detect:' + str('{:,}'.format(sum(df_counts.Time))) +
|
||||
' Confidence Max:' + str('{:.2f}%'.format(max(df2[df2['Com_Name'] == specie]['Confidence']) * 100)) +
|
||||
' '+' Median:'+str('{:.2f}%'.format(np.median(df2[df2['Com_Name']==specie]['Confidence'])*100))
|
||||
' ' + ' Median:' +
|
||||
str('{:.2f}%'.format(np.median(df2[df2['Com_Name'] == specie]['Confidence']) * 100))
|
||||
)
|
||||
)
|
||||
fig.layout.annotations[1].update(x=0.7, y=0.25, font_size=15)
|
||||
@@ -147,15 +148,16 @@ fig.update_layout(
|
||||
rotation=-90,
|
||||
direction='clockwise',
|
||||
tickmode='array',
|
||||
tickvals=[0,15,35,45,60,75,90,105,120,135,150,165,180,195,210,225,240,255,270,285,300,315,330,345],
|
||||
ticktext=['12am','1am','2am','3am','4am','5am', '6am','7am','8am','9am','10am','11am','12pm','1pm','2pm','3pm','4pm','5pm', '6pm','7pm','8pm','9pm','10pm','11pm'],
|
||||
tickvals=[0, 15, 35, 45, 60, 75, 90, 105, 120, 135, 150, 165,
|
||||
180, 195, 210, 225, 240, 255, 270, 285, 300, 315, 330, 345],
|
||||
ticktext=['12am', '1am', '2am', '3am', '4am', '5am', '6am', '7am', '8am', '9am', '10am', '11am',
|
||||
'12pm', '1pm', '2pm', '3pm', '4pm', '5pm', '6pm', '7pm', '8pm', '9pm', '10pm', '11pm'],
|
||||
hoverformat="#%{theta}: <br>Popularity: %{percent} </br> %{r}"
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
daily = pd.crosstab(df2['Com_Name'], df2.index.date, dropna=False)
|
||||
|
||||
fig.add_trace(go.Bar(x=daily.columns, y=daily.loc[specie]), row=3, col=2)
|
||||
|
||||
Reference in New Issue
Block a user