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 glob | |
| import zipfile | |
| # Assume there's a directory 'test-dir' with few .txt files in it | |
| files = glob.glob("test-dir/*.txt") | |
| zip_file = zipfile.ZipFile('test.zip', 'w') | |
| with zip_file: | |
| # writing each file one by one | |
| for file in files: | |
| zip_file.write(file) |
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 glob | |
| import zipfile | |
| # Assume there's a directory 'test-dir' with few .txt files in it | |
| files = glob.glob("test-dir/*.txt") | |
| zip_file = zipfile.ZipFile('test.zip', 'w') | |
| with zip_file: | |
| # writing each file one by one | |
| for file in files: | |
| zip_file.write(file) |
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 glob | |
| import zipfile | |
| # Assume there's a directory 'test-dir' with few .txt files in it | |
| files = glob.glob("test-dir/*.txt") | |
| zip_file = zipfile.ZipFile('test.zip', 'w') | |
| with zip_file: | |
| # writing each file one by one | |
| for file in files: | |
| zip_file.write(file) |
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
| exports.handler = async (event, context) => { | |
| let count = 0; | |
| event.Records.forEach(record => { | |
| console.log('RECEIVE RECORD: ' + JSON.stringify(record, null, 4)); | |
| count++; | |
| }); | |
| return {'records' : count}; | |
| } |
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
| from presidio_analyzer import AnalyzerEngine | |
| import json | |
| engine = AnalyzerEngine() | |
| inputText = "Yo! Brandon is your SSN 100-11-1111? I want to charge $10.0 to your card 5555555555554444. Call me at 215-327-8888. I will pay you back at 36036545555" | |
| # https://microsoft.github.io/presidio/field_types.html | |
| response = engine.analyze(correlation_id=0, | |
| text=inputText, |
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 folium as folium | |
| # Function to color code categories for number of positive cases | |
| def get_icon_color(cases): | |
| if cases <= 10: | |
| return 'green' | |
| elif cases > 10 and cases < 100: | |
| return 'orange' | |
| else: | |
| return 'red' |
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
| # Plot lines | |
| ax = df_diff.plot(colormap='jet', marker='.', markersize=10, | |
| title='Daily Changes in Cases', figsize=(20,10)) | |
| # set labels for X and Y axes | |
| ax.set_xlabel("Count") | |
| ax.set_ylabel("Date") |
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
| # Reload DataFrame and sort by Date | |
| df_summary = pd.read_csv("pa_summary.csv") | |
| # convert column to Integer for calculation | |
| df_summary = df_summary.astype({"Positive": int, "Negative": int, "Deaths" : int}) | |
| df_summary['Tested'] = df_summary['Positive'] + df_summary['Negative'] | |
| # Set Index and sort by Date | |
| df_summary.set_index('Date', inplace=True) | |
| df_summary = df_summary.sort_values('Date', ascending = True) |
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
| # Setup DataFrame for plotting | |
| df_percent = pd.DataFrame(df, columns=['Date', 'Positive_Percent','Negative_Percent']) | |
| df_percent.set_index("Date", inplace = True) | |
| # Plot bar charts | |
| style.use('ggplot') | |
| bar_chart = df_percent.plot.bar(stacked=False, width=0.8, figsize=(20,15), title="Percentage of Positive and Negative Cases") | |
| plt.xlabel('Date') | |
| plt.ylabel('Percentage') | |
| bar_chart.legend(loc=2) |
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
| # Plot PA COVID-19 cases to date | |
| style.use('ggplot') | |
| ax = plt.gca() | |
| df.plot(kind='line',x='Date',y='Positive', color='green', ax=ax, figsize=(20,10)) | |
| df.plot(kind='line',x='Date',y='Negative', color='blue', ax=ax) | |
| df.plot(kind='line',x='Date',y='Deaths', color='red', ax=ax) | |
| df.plot(kind='line',x='Date',y='Tested', color='black', ax=ax) | |
| plt.title('Number of Cases and Deaths by Date') | |
| plt.xlabel('Date') | |
| plt.ylabel('Count') |
NewerOlder