<jupyter_start><jupyter_text>ft_ids.items()<jupyter_code>np.random.rand(100)
pogoda["datetime_d"] = pd.to_datetime(pogoda["datetime_d"])

with open("pogoda.pkl", "wb") as f:
    pickle.dump(pds[0],f)
import pydeck as pdk

UK_ACCIDENTS_DATA = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/3d-heatmap/heatmap-data.csv'
df = pd.read_csv(UK_ACCIDENTS_DATA)
df["lat"] = 51
df.iloc[0]
pogoda["lng"] = pogoda.lon

def_date= pd.to_datetime('2020-07-01 00:00:00')
pogoda["check"] = pogoda["winddirection"].apply(lambda x: random.randint(0,255))
check_df = pogoda[(pogoda.datetime_d == def_date)&(pogoda.lon<60)&(pogoda.lat<60)&(pogoda.lon>40)&(pogoda.lat>40)]
df[:10]
import numpy as np
import colorsys
def _get_colors(num_colors):
    colors=[]
    for i in np.arange(0., 360., 360. / num_colors):
        hue = i/360.
        lightness = (50 + np.random.rand() * 10)/100.
        saturation = (90 + np.random.rand() * 10)/100.
        colors.append(colorsys.hls_to_rgb(hue, lightness, saturation))
    return colors
_get_colors(5)[0][0]
def color_funct(x):
    with open("tttt.txt","w") as f:
        f.write(str(x))
        
    return [155,0,144,255]
"""
ColumnLayer
===========

Real estate values for select properties in Taipei. Data is from 2012-2013.
The height of a column indicates increasing price per unit area, and the color indicates distance from a subway stop.

The real estate valuation data set from UC Irvine's Machine Learning repository, viewable here:

https://archive.ics.uci.edu/ml/datasets/Real+estate+valuation+data+set
"""

import pandas as pd
import pydeck as pdk

DATA_URL = "https://raw.githubusercontent.com/ajduberstein/geo_datasets/master/housing.csv"
df = pd.read_csv(DATA_URL)
df = check_df
view = pdk.data_utils.compute_view(df[["lng", "lat"]])
view.pitch = 75
view.bearing = 60
view_state = pdk.ViewState(
    longitude=47.415,
    latitude=46.2323,
    zoom=6,
    min_zoom=5,
    max_zoom=15,
    pitch=40.5,
    bearing=-27.36)
column_layer = pdk.Layer(
    "ColumnLayer",
    data=df,
    get_position=["lng", "lat"],
    get_elevation=["temperature"],
    elevation_scale=1000,
    radius=20000,
    get_fill_color= ["check",0,0],
    pickable=True#,
   # auto_highlight=True,
)

tooltip = {
    "html": "<b>{mrt_distance}</b> meters away from an MRT station, costs <b>{price_per_unit_area}</b> NTD/sqm",
    "style": {"background": "grey", "color": "white", "font-family": '"Helvetica Neue", Arial', "z-index": "10000"},
}

r = pdk.Deck(
    column_layer,
    initial_view_state=view,
    #tooltip=tooltip,
    #map_provider="mapbox",
    map_style=pdk.map_styles.LIGHT
    #pdk.map_styles.SATELLITE,
)

r.to_html("column_layer.html")
f = lambda x=0: 1

"""
ColumnLayer
===========

Real estate values for select properties in Taipei. Data is from 2012-2013.
The height of a column indicates increasing price per unit area, and the color indicates distance from a subway stop.

The real estate valuation data set from UC Irvine's Machine Learning repository, viewable here:

https://archive.ics.uci.edu/ml/datasets/Real+estate+valuation+data+set
"""

import pandas as pd
import pydeck as pdk

DATA_URL = "https://raw.githubusercontent.com/ajduberstein/geo_datasets/master/housing.csv"
df = pd.read_csv(DATA_URL)

view = pdk.data_utils.compute_view(df[["lng", "lat"]])
view.pitch = 75
view.bearing = 60

column_layer = pdk.Layer(
    "ColumnLayer",
    data=df,
    get_position=["lng", "lat"],
    get_elevation="price_per_unit_area",
    elevation_scale=100,
    radius=50,
    get_fill_color=["mrt_distance * 10", "mrt_distance", "mrt_distance * 10", 140],
    pickable=True,
    auto_highlight=True,
)
# Set the viewport location
view_state = pdk.ViewState(
    longitude=-1.415,
    latitude=52.2323,
    zoom=6,
    min_zoom=5,
    max_zoom=15,
    pitch=40.5,
    bearing=-27.36)

tooltip = {
    "html": "<b>{mrt_distance}</b> meters away from an MRT station, costs <b>{price_per_unit_area}</b> NTD/sqm",
    "style": {"background": "grey", "color": "white", "font-family": '"Helvetica Neue", Arial', "z-index": "10000"},
}

r = pdk.Deck(
    column_layer,
   initial_view_state=view,
   # tooltip=tooltip,
    #map_provider="mapbox",
 map_style=pdk.map_styles.LIGHT,
)

res = r.to_html("column_layer.html")
 r.to_html().data
import pydeck as pdk

UK_ACCIDENTS_DATA = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/3d-heatmap/heatmap-data.csv'

layer = pdk.Layer(
    'HexagonLayer',  # `type` positional argument is here
    UK_ACCIDENTS_DATA,
    get_position=['lng', 'lat'],
    auto_highlight=True,
    elevation_scale=50,
    pickable=True,
    elevation_range=[0, 3000],
    extruded=True,
    coverage=1)

# Set the viewport location
view_state = pdk.ViewState(
    longitude=-1.415,
    latitude=52.2323,
    zoom=6,
    min_zoom=5,
    max_zoom=15,
    pitch=40.5,
    bearing=-27.36)
f = 0
def filter_by_viewport(c):
    global f
    f=c
    print(str(c))
# Combined all of it and render a viewport
r = pdk.Deck(layers=[layer], initial_view_state=view_state)
r.deck_widget.on_click(filter_by_viewport)

r.to_html('hexagon-example.html')
f
from ipywidgets import HTML

text = HTML(value='Move the viewport')
layer = pdk.Layer(
    'ScatterplotLayer',
    df,
    pickable=True,
    get_position=['lng', 'lat'],
    get_fill_color=[255, 0, 0],
    get_radius=100
)
r = pdk.Deck(layer, initial_view_state= pdk.data_utils.compute_view(df))

def filter_by_bbox(row, west_lng, east_lng, north_lat, south_lat):
    return west_lng < row['lng'] < east_lng and south_lat < row['lat'] < north_lat

def filter_by_viewport(widget_instance, payload):
    try:
        west_lng, north_lat = payload['data']['nw']
        east_lng, south_lat = payload['data']['se']
        filtered_df = df[df.apply(lambda row: filter_by_bbox(row, west_lng, east_lng, north_lat, south_lat), axis=1)]
        text.value = 'Points in viewport: %s' % int(filtered_df.count()['lng'])
    except Exception as e:
        text.value = 'Error: %s' % e


r.deck_widget.on_click(filter_by_viewport)
display(text)
r.show()
!pip install<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14978765109441358, 'fraction_numerical': 0.03511924207775237, 'mean_word_length': 4.242294520547945, 'pattern_counts': {'":': 12, '<': 19, '<?xml version=': 0, '>': 15, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '62215', 'license': 'MIT', 'n_tokens_mistral': 2475, 'n_tokens_neox': 2302, 'n_words': 465, 'path': 'Energy_sandbox.ipynb', 'repo_name': 'fireresistance/Energo', 'size': '6122'}