Skip to content

Instantly share code, notes, and snippets.

import os
import requests
import numpy as np
import pandas as pd
import json
def create_tf_serving_json(data):
return {'inputs': {name: data[name].tolist() for name in data.keys()} if isinstance(data, dict) else data.tolist()}
def score_model(dataset):
@bojanbabic
bojanbabic / address_to_hood_id.py
Last active September 22, 2023 16:03
Address to Hood Id
import pandas as pd
from nextdoor.i18n import locale_api
from nextdoor.gql.geo.geo_tag_utils import get_neighborhood_from_lat_lon
from nextdoor.common.mapbox import mapbox_client
locale_api.set_locales('en-us')
csv_file = "/app/CA_ncesdata_642B9065_cleaned.csv"
output_file = "/app/CA_ncesdata_642B9065_hood_id.csv"
df = pd.read_csv(csv_file)
def get_lat_lon(row):
import openai
import os
from bs4 import BeautifulSoup
from bs4.element import Comment
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
import re
openai.api_key = os.getenv('OPENAI_API_KEY')
We can make this file beautiful and searchable if this error is corrected: No tabs found in this TSV file in line 0.
1b306d19-fe12-46a1-a3f3-1d4583eac980
8ea5017f-7d53-484f-8729-d19ab512d2c5
4a19ba2c-6b52-4ae4-aadf-10748b24e0f7
2118983e-35ef-4b18-9ded-b8388968abe5
c5e4b106-199f-4fea-9665-8f76905a055e
a95d4547-faae-4bd7-9f7d-4b4613fa7887
63c5b390-10eb-4e82-a0c2-e4fff11bd677
d652a9ef-012e-4ca1-8e60-8f888f2ada65
35cf66bf-4fae-4bef-83c5-98ec3ddd4ef0
0d42b580-26fb-48ac-b498-cdf93111de45
# curl "https://www.airbnb.com/api/v2/autocompletes?country=US&key=d306zoyjsyarp7ifhu67rjxn52tv0t20&language=en&locale=en&num_results=5&user_input=yoga&api_version=1.2.0&vertical_refinement=all&region=1&options=should_show_stays" | jq '.autocomplete_terms[0] '
{
"id": "78f3c2985523dd6742202ebcddcc02604d5af94f5ecd6c44414b86d24d6640c7",
"explore_search_params": {
"refinement_paths": [
"/experiences/KG/Tag:76"
],
"reset_filters": false,
"reset_keys": [],
"query": "Yoga in San Diego, CA",
This file has been truncated, but you can view the full file.
{
"cards": [
{
"cardType": "BAND",
"data": {
"name": [
"INTENT_BAND"
]
}
},
0xdata
1%-of-nothing
1-800-dentist
1-800-flowers-com
1-of-nothing
1-page
1-web-design
10-downing-street
10-foot-wave
1000memories
#!/usr/bin/perl
#author Bojan Babic
#email:[email protected]
use Time::HiRes qw /gettimeofday/;
use LWP::UserAgent;
use LWP::Simple;
use HTTP::Request;
use HTTP::Response;
use strict;