This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @app.route('/login', methods=['POST', 'GET']) | |
| def login(): | |
| form = LoginForm() | |
| if form.validate_on_submit(): | |
| user = User.query.filter_by(email=form.email.data).first() | |
| if user is None: | |
| flash('Please register to gain access', category='danger') | |
| return redirect(url_for('register')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fig = px.bar(plot_df, x='Provider County', y="Observed Prescribing Rate per 100 Visits", color="Provider County", | |
| animation_frame="Year", animation_group="Provider County", range_y=[3, 70], | |
| title='Antibiotic Prescribing rates in US counties') | |
| fig.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| keys = [i for i in range(65)] | |
| all_dataframes = {} | |
| for i, county in zip(keys, df['Provider County'].unique()): | |
| df2 = df[df['Provider County'] == county].sort_values('Year', ascending=True) | |
| all_dataframes[i] = df2 | |
| master_df = [] | |
| for i in all_dataframes: | |
| master_df.append(all_dataframes[i]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import plotly.express as px | |
| pd.set_option('display.max_rows', None) | |
| pd.set_option('display.max_columns', None) | |
| df = pd.read_csv('potentially-avoidable-antibiotic-prescribing-rates.csv') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fig, ax = plt.subplots(figsize=(14, 16)) | |
| res_geo.plot(ax=ax, figsize=(14, 16), column=res_geo['resistance_scores'], cmap='cool', k=6, | |
| missing_kwds=dict(color="lightgrey",label='No Data/<10 isolates'), | |
| scheme='FisherJenks', | |
| edgecolor = 'black', | |
| legend=True, | |
| linewidth = 0.1, | |
| legend_kwds=dict(loc='lower left', frameon=False, title='Resistance Scores')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| res_geo.plot(figsize=(12, 16), column=res_geo['resistance_scores'], cmap='OrRd', | |
| edgecolor = 'black', | |
| linewidth = 0.1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data = gdf[gdf['country'].isin(res['country'].to_list())] | |
| res_df = res.merge(data, on='country') | |
| others = gdf[~gdf['country'].isin(res['country'].to_list())] | |
| others['resistance_scores'] = np.NaN | |
| res_geo = pd.concat([res_df, others]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data_countries = res['country'].to_list() | |
| all_countries = gdf['country'].to_list() | |
| same_countries = [] | |
| different_countries = [] | |
| for country in data_countries: | |
| if country not in all_countries: | |
| different_countries.append(country) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| res = pd.DataFrame(res.groupby('country').mean()['resistance_scores'].sort_values(ascending=False)) | |
| res = res[res.index.isin(representative_countires)].reset_index() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| res = pd.read_csv('resistance_score__Country__res_0-3_vir_0-5.csv') | |
| res['resistance_scores'] = res['annotation'].apply(lambda x: int(x[0])) | |
| res.drop('annotation', axis=1, inplace=True) | |
| res.columns = ['country', 'resistance_scores'] | |
| res.groupby('country').mean()['resistance_scores'].sort_values(ascending=False) |