This file contains 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
colors = ['aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure', | |
'beige', 'bisque', 'black', 'blanchedalmond', 'blue', | |
'blueviolet', 'brown', 'burlywood', 'cadetblue', | |
'chartreuse', 'chocolate', 'coral', 'cornflowerblue', | |
'cornsilk', 'crimson', 'cyan', 'darkblue', 'darkcyan', | |
'darkgoldenrod', 'darkgray', 'darkgrey', 'darkgreen', | |
'darkkhaki', 'darkmagenta', 'darkolivegreen', 'darkorange', | |
'darkorchid', 'darkred', 'darksalmon', 'darkseagreen', | |
'darkslateblue', 'darkslategray', 'darkslategrey', | |
'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', |
This file contains 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.query('a in ["a", "b", "c"]') | |
id_list = ["a", "b", "c"] | |
df.query('a in @id_list') |
This file contains 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
SUBSTR(FORMAT("00%d", state_fips ), -2) as state_fips, | |
SUBSTR(FORMAT("00000%d", fips ), -5) as fips, |
This file contains 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
ARRAY_TO_STRING(homeContext.fipscode, ',') |
This file contains 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 cartoframes.viz import Map, Layer, basemaps | |
from cartoframes.viz import Layer, color_continuous_style, color_bins_style, basic_style, color_category_legend | |
_df = average_duration.copy() | |
metric = 'avg_duration_day' | |
origin_county = selected_area_geom.iloc[0]['county_name'] | |
origin_state = selected_area_geom.iloc[0]['state_name'] |
This file contains 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
slack_message = "Home & Work for bundleId {} is ready for shipping!".format("{{ ti.xcom_pull(task_ids='get_bundle_id') }}") | |
notify_slack = SimpleHttpOperator( | |
task_id="notify_slack", | |
endpoint=slack_webhook_url, | |
data=json.dumps( | |
{"attachments": [{"fallback": slack_message, "text": slack_message, "color": "good"}]}), | |
headers={"Content-Type": "application/json"}, | |
depends_on_past=False, | |
response_check=lambda response: True if response.status_code == 200 else False, | |
http_conn_id="http_slack_hook" |
This file contains 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
!pip install plotly==4.8 | |
# Quick way to install hind font | |
!npm install -g google-font-installer | |
!gfi install hind -v 300 | |
import plotly.graph_objs as go | |
import plotly.io as pio | |
pd.options.plotting.backend = "plotly" |
This file contains 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 TABLE dataset.new_table | |
PARTITION BY DATE(timestamp_column) AS | |
SELECT x, y, z, timestamp_column | |
FROM dataset.existing_table | |
CREATE OR REPLACE TABLE `uc-prox-core-dev.14_days_retention.home_od_flux_2020_aggregated_condensed` | |
PARTITION BY minProcessingDate | |
AS | |
SELECT... |
This file contains 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 | |
pd.options.display.max_columns = 50 # None -> No Restrictions | |
pd.options.display.max_rows = 200 # None -> Be careful with this | |
pd.options.display.max_colwidth = 100 | |
pd.options.display.precision = 3 |
This file contains 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.DataFrame(dict(A=[2,6,3], | |
B=[2,2,6], | |
C=[3,2,3])) | |
df['col_total'] = df.apply(lambda x: x.sum(), axis=1) | |
df.loc['row_total'] = df.apply(lambda x: x.sum()) |
OlderNewer