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 sqlalchemy import create_engine | |
| import pandas as pd | |
| params = urllib.parse.quote_plus( | |
| r'Driver={ODBC Driver 17 for SQL Server};' | |
| + fr'Server={sql_server}' | |
| + fr',1433;Database={sql_db};' | |
| + fr'Uid={sql_user};Pwd={sql_password};' | |
| + r'Encrypt=yes;TrustServerCertificate=Yes;Connection Timeout=30;') |
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 numpy as np | |
| NaN = np.nan | |
| def is_nums(numbers : tuple) -> bool: | |
| return all((isinstance(num, (int,float)) for num in numbers)) | |
| #is_nums(1, 4, 3, 2, 5) | |
| #True | |
| #is_nums(1, "a", 3) | |
| #False |
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 requests | |
| import json | |
| import base64 | |
| import pprint | |
| import unittest | |
| import time | |
| import datetime | |
| # Put this in contactMechList | |
| ADDRESS_TEMPLATE = { |
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
| CREATE PROCEDURE [stg_ecp].[p_InsertDwFactProductPrices] | |
| @jobKey int | |
| AS | |
| BEGIN | |
| /* ================================================================================================================== | |
| Description: Create Fact Table for Products. | |
| ================================================================================================================== */ | |
| SET NOCOUNT ON -- Eliminate any dataset counts |
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
| df = pd.read_csv('GlobalLandTemperaturesByCountry.csv') | |
| df = df.dropna(subset=['AverageTemperature']) | |
| df['dt'] = pd.to_datetime(df['dt']) | |
| df = df[df['dt'].dt.year >= 1900] | |
| df = df.drop(['AverageTemperatureUncertainty'], axis=1) | |
| df_group = df.groupby(dfRead['dt'].dt.year)['AverageTemperature'].mean().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
| {% extends '_base.html' %} | |
| {% load crispy_forms_tags %} | |
| {% block javascript %} | |
| <!--Chart js--> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js" integrity="sha256-Uv9BNBucvCPipKQ2NS9wYpJmi8DTOEfTA/nH2aoJALw=" crossorigin="anonymous"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.css" integrity="sha256-aa0xaJgmK/X74WM224KMQeNQC2xYKwlAt08oZqjeF0E=" crossorigin="anonymous" /> | |
| <!-- jQuery --> | |
| <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> | |
| {% endblock javascript %} |
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 django.db import models | |
| class Carbon(models.Model): | |
| id = models.AutoField( | |
| primary_key=True, | |
| editable=False, | |
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 .models import Carbon | |
| from django.db.models import Q | |
| from django.views.generic import ListView | |
| from datetime import datetime | |
| class CarbonDataView(ListView): | |
| model = Carbon | |
| context_object_name = 'carbon' |
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 | |
| rows = [{'dt' : '2020-01-01 12:00:00'}, | |
| {'dt' : '2020-01-04 13:00:00'}, | |
| {'dt' : '2020-01-08 14:00:00'}, | |
| {'dt' : '2020-01-09 15:00:00'}] | |
| dt = pd.DataFrame(rows) | |
| dt['dt'] = pd.to_datetime(dt['dt'],format='%Y-%m-%d') |
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
| def generate_new_keys(*args,key='Carid',name='Carname'): | |
| """ | |
| Takes in a number of dataframes and returns any duplicates with a new unique id. | |
| groupby columns fixed to CarID and CarName. | |
| """ | |
| # adds dictionaries into a single list. | |
| dicts_ = [arg.groupby(key)[name].first().to_dict() for arg in args] | |
| #merges dicts on unique key, this will exclude duplicates. | |
| merged_dicts = dict(ChainMap(*dicts_)) |
NewerOlder