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
# List unique values in a DataFrame column | |
# h/t @makmanalp for the updated syntax! | |
df['Column Name'].unique() | |
# Convert Series datatype to numeric (will error if column has non-numeric values) | |
# h/t @makmanalp | |
pd.to_numeric(df['Column Name']) | |
# Convert Series datatype to numeric, changing non-numeric values to NaN | |
# h/t @makmanalp for the updated syntax! |
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 9.
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
Asset,Type,Asset Value,Debt,Net Value,Change vs 2015,Change,Stake,Latitude,Longitude,Notes | |
Trump Tower (New York City),Office and retail,471,100,371,-159,Down,1,40.768277,-73.981455,Opened 1983 | |
1290 Avenue of the Americas (New York City),Office and retail,2310,950,408,-62,Down,0.3,40.768277,-73.981455, | |
Niketown (New York City),Office and retail,400,10,390,-52,Down,1,40.768277,-73.981455,Ground lease through 2079 | |
40 Wall Street (New York City),Office and retail,501,156,345,-28,Down,1,40.768277,-73.981455, | |
Trump Park Avenue (New York City),Residential and retail,191,14.3,176.7,-27,Down,1,40.768277,-73.981455,"49,564 sq. ft. of condos; 27,467 sq. ft. of retail" | |
Trump Parc/Trump Parc East (New York City),Residential and retail,88,0,88,17,Up,1,40.768277,-73.981455,"11,750 sq. ft. of condos; 14,963 sq. feet of retail; 13,108 sq. ft. of garage" | |
"Trump International Hotel and Tower, Central Park West (New York City)","Hotel, condos and retail",38,0,38,21,Up,1,40.768277,-73.981455, | |
"Trump World Tower, 845 United Natio |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# TODO - REPLACE WITH SA ACCOUNT KEY | |
KEY_FILE = '/<path-to-your-service-account-file>/file.json' #REPLACE THIS WITH PROJECT SPECIFIC SERVICE ACCOUNT KEY | |
ts_endpoint = f'https://timeseriesinsights.googleapis.com/v1/projects/{PROJECT_ID}/datasets' | |
# Helper function | |
def query_ts(method, endpoint, data, auth_token): | |
data = str(data) | |
headers = {'Content-type': 'application/json', "Authorization": f"Bearer {auth_token}"} | |
if method == "GET": |
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
#list all API datasets | |
res = query_ts(method="GET", endpoint=ts_endpoint, data=None, auth_token=token) | |
res |
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
new_event_payload = { | |
{ | |
"events": [ | |
{ | |
"groupId":"1324354349507023708", | |
"dimensions":[ | |
{"name":"measure","stringVal":"LTTH"}, | |
{"name":"Humidity","doubleVal":36}, | |
{"name":"Light","doubleVal":99}, | |
{"name":"h2_raw","doubleVal":1041}, |
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
delete_ds_endpt = f'https://timeseriesinsights.googleapis.com/v1/projects/{PROJECT_ID}/datasets/{dataset}' | |
res = query_ts(method="DELETE", endpoint=delete_ds_endpt, data=None, auth_token=token_array[0]) | |
res |
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 json payload for API query | |
request_body = { | |
"detectionTime": "2021-06-27T15:00:00Z", | |
"slicingParams": { | |
"dimensionNames": ["measure"] | |
}, | |
"timeseriesParams": { | |
"forecastHistory": "259200s", | |
"granularity": "1800s", | |
"metric": "temp", |
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
evaluate_slice_payload = { | |
"detectionTime": "2021-08-09T21:31:54+00:00", | |
"pinnedDimensions": [ | |
{ | |
"name": "measure", | |
"stringVal": "LTTH" | |
} | |
], | |
"timeseriesParams": { | |
"forecastHistory": "259200s", |
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
google-auth | |
requests==2.24.0 | |
numpy==1.22.3 | |
oauth2client | |
google-cloud-bigquery==3.3.1 |
OlderNewer