One Paragraph of project description goes here
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
| """ lists environment variables, and splits elements in path variable """ | |
| import os | |
| for k, v in sorted(os.environ.items()): | |
| print(k+':', v) | |
| print('\n') | |
| # list elements in path environment variable | |
| [print(item) for item in os.environ['PATH'].split(';')] |
| """ | |
| author: Bill Thaman | |
| description: Uses a genetic algorithm, with selective pressure, to find the optimal combination | |
| of projects where the sum of costs is less than or equal to a total. Inspired by the knapsack problem. | |
| """ | |
| from random import randint, random | |
| from operator import add | |
| from functools import reduce | |
| import roulette | |
| import project |
| import requests | |
| def download_file(url, out_file_name): | |
| try: | |
| pdf_url = url | |
| r = requests.get(pdf_url) | |
| with open(out_file_name, 'wb') as f: | |
| f.write(r.content) |
| import os | |
| def get_download_path(): | |
| """Returns the default downloads path for linux or windows""" | |
| if os.name == 'nt': | |
| import winreg | |
| sub_key = r'SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders' | |
| downloads_guid = '{374DE290-123F-4565-9164-39C4925E467B}' | |
| with winreg.OpenKey(winreg.HKEY_CURRENT_USER, sub_key) as key: |
| import sys | |
| ''' | |
| list paths that Python searches for packages. | |
| see https://leemendelowitz.github.io/blog/how-does-python-find-packages.html for the whole story. | |
| an example of a path Python searches are the paths listed in the PYTHONPATH environment variable. | |
| ''' | |
| print('\n'.join(sys.path)) |
| # List unique values in a DataFrame column | |
| # h/t @makmanalp for the updated syntax! | |
| df['Column Name'].unique() | |
| # For each unique value in a DataFrame column, get a frequency count | |
| df['Column Name'].value_counts() | |
| # Convert Series datatype to numeric (will error if column has non-numeric values) | |
| # h/t @makmanalp | |
| pd.to_numeric(df['Column Name']) |
People
:bowtie: |
π :smile: |
π :laughing: |
|---|---|---|
π :blush: |
π :smiley: |
:relaxed: |
π :smirk: |
π :heart_eyes: |
π :kissing_heart: |
π :kissing_closed_eyes: |
π³ :flushed: |
π :relieved: |
π :satisfied: |
π :grin: |
π :wink: |
π :stuck_out_tongue_winking_eye: |
π :stuck_out_tongue_closed_eyes: |
π :grinning: |
π :kissing: |
π :kissing_smiling_eyes: |
π :stuck_out_tongue: |
| SELECT T.name AS Table_Name , | |
| C.name AS Column_Name , | |
| P.name AS Data_Type , | |
| P.max_length AS Size , | |
| CAST(P.precision AS VARCHAR) + '/' + CAST(P.scale AS VARCHAR) AS Precision_Scale | |
| FROM sys.objects AS T | |
| JOIN sys.columns AS C ON T.object_id = C.object_id | |
| JOIN sys.types AS P ON C.system_type_id = P.system_type_id | |
| WHERE T.type_desc = 'USER_TABLE'; |
| """ | |
| Demonstrate how to keep your SQL Server database consistent when performing a series of updates using pyodbc, and something goes wrong | |
| somewhere in the middle of it all. | |
| Transactions are managed at the connection level (not the cursor level). When creating the connection, set autocommit=False. | |
| When a command (e.g., an update) is executed against the connection, it will not be committed automatically. | |
| If you are executing multiple commands against the connection, and an error is raised before all the commands are complete, | |
| your database may not be consistent. But, since the commands were not committed, it's ok. | |